#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()

template <typename T, typename E>
ostream &operator<<(std::ostream &os, const std::pair<T, E> &p){
  return os << "(" << p.first << ", " << p.second << ")";
}

typedef long long ll;

const int RMAX = 200010;
ll BIT[RMAX];

void add(int pos, ll x){
  while (pos < RMAX){
    BIT[pos] += x;
    pos += -pos & pos;
  }
}

ll sum(int pos){
  ll res = 0;
  while (pos > 0){
    res += BIT[pos];
    pos -= -pos & pos;
  }
  return res;
}
int main(){
  ios::sync_with_stdio(false);
  ll A, B, P;
  while (cin >> A>> B >> P && A + B + P){
    memset(BIT, 0, sizeof(BIT));
    vector<string> numbers;
    for (ll i = A; i <= B; i++) numbers.push_back(to_string(i));
    sort(ALL(numbers));

    ll res = 0;

    REP(i, numbers.size()){
      ll offset = atoi(numbers[i].c_str()) - A;
      ll dp_value = (sum(offset + 1) + 1) % P;
      add(offset + 1, dp_value);
      
      res += dp_value;
      res %= P;
    }
    cout << res << endl;
  }
  return 0;
}