#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

template<typename T> class BinaryIndexedTree {
  vector<T> vec;
  const ll n, mod;

public:
  BinaryIndexedTree(T _n, ll mod) : vec(_n + 1), n(_n), mod(mod) {}

  T query(ll x) {
    T ret = 0;
    for(ll i = x; i > 0; i -= i & (-i)) (ret += vec[i]) %= mod;
    return ret;
  }

  void update(ll x, T k) {
    for(ll i = x; i <= n; i += i & (-i)) (vec[i] += k) %= mod;
  }
};

int main(void) {
  ll A, B, P;
  while(cin >> A >> B >> P, B++, A && B && P) {
    vector<pair<string, ll>> s(B - A);
    REP(i, 0, B - A) s[i] = pair<string, ll>(to_string(i + A), i);
    sort(s.begin(), s.end());

    ll ans = 0;
    BinaryIndexedTree<ll> bit(B - A + 1, P);
    bit.update(1, 1);
    REP(i, 0, B - A) {
      ll x = s[i].second + 2;
      bit.update(x, bit.query(x));
    }
    cout << (bit.query(B - A + 1) - 1 + P) % P << endl;
  }
}
