#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <iostream>
using namespace std;
using ll = long long int;

const int MAXB = 100010;
ll A, B, P, dp[MAXB + 10], base[15];

ll add_dp(ll ub, ll digit, ll isOp) {
  // [lb, ub]
  if(isOp) ub--;
  ll lb = base[digit];

  if(lb > ub) return 0;
  if(B < lb or ub < A) return 0;
  ll mi = max(A, lb), ma = min(B, ub);
  ll idxMi = mi - A + 1, idxMa = ma - A + 1;

  // fprintf(stderr, "lb = %lld, ub = %lld, digit = %lld, mi = %lld, ma = %lld\n", lb, ub, digit, mi, ma);
  return (dp[idxMa] - dp[idxMi - 1] + P) % P;
}

ll solve() {
  fill(dp, dp + MAXB, 0);

  ll width = B - A + 1;
  for(int i=0; i<width; i++) {
    dp[i+1] = 1;
    ll num = A + i;
    string s = to_string(num);
    ll ub = 0;

    for(size_t k=0; k<s.length(); k++) {
      ub = ub * 10 + (s[k] - '0');
      (dp[i+1] += add_dp(ub, k+1, k+1 == s.length())) %= P;
    }

    (dp[i+1] += dp[i]) %= P;
  }
  return dp[width];
}

int main() {
  base[1] = 1;
  for(int i=2; i<15; i++) {
    base[i] = base[i-1] * 10;
  }
  
  while(cin >> A >> B >> P, A) {
    cout << solve() << endl;
  }
  return 0;
}

