#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<17;

ll mod;
class BIT2{
public:
  int n;
  ll bit0[MAX_N+1],bit1[MAX_N+1];//1????????????

  BIT2(){n = MAX_N;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  BIT2(int n){this->n=n;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  
  ll sum(ll *b,int i){
    ll s=0;
    while(i>0){
      s=(s+b[i])%mod;
      i-=i&-i;
    }
    return s;
  }

  void add(ll *b,int i,ll v){
    while(i<=n){
      b[i]=(b[i]+v)%mod;
      i+=i&-i;
    }
  }

  //[a,b]???x?????????(1<=a)
  void add (int a,int b,ll x){
    add(bit0,a,-x*(a-1));
    add(bit1,a,x);
    add(bit0,b+1,x*b);
    add(bit1,b+1,-x);
  }

  //[a,b]???sum?????????(1<=a)
  ll sum(int a,int b){
    ll res=0;
    res+=sum(bit0,b)+sum(bit1,b)*b;
    res-=sum(bit0,a-1)+sum(bit1,a-1)*(a-1);
    return (res+mod)%mod;    
  }
};

string i2S(ll num){
  string res;
  if(num==0)return "0";
  while(num) res+=(char)(num%10+'0'),num/=10;
  reverse(res.begin(),res.end());
  return res;
}

int main(){
  while(1){
    ll A,B;
    cin>>A>>B>>mod;
    if(!A&&!B&&!mod)return 0;
    vector<string> num;
    for(ll i=A;i<=B;i++)num.push_back(i2S(i));
    sort(num.begin(),num.end());
  
    ll ans = 0, n = B-A+2;
    BIT2 T(n);
    T.add(1,n,1);
    
    for(ll i=A;i<=B;i++){
      int idx = lower_bound(num.begin(),num.end(),i2S(i))-num.begin()+1;
      ll val = T.sum(idx,idx);
      ans=(ans+val)%mod;
      T.add(idx,n,val);
    }
    cout<<ans<<endl;
  }
  return 0;
}