#include<bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

string itos(int x){
  string res;
  while(x)res+=x%10+'0',x/=10;
  reverse(res.begin(),res.end());
  return res;
}

ll dp[N][11];

int main(){

  while(1){
    
    ll a,b,p;

    cin>>a>>b>>p;

    if(!a&&!b&&!p) break;
    
    vector<string> v;
  
    for(int i=a;i<=b;i++) v.push_back(itos(i));
  
    ll n=b-a+1;
  
    sort(v.begin(),v.end());
  
    v.push_back("");
  
    memset(dp,0,sizeof(dp));
  
    for(int i=0;i<n;i++) dp[i][v[i].size()]=1;
  
    for(int i=0;i<n;i++){
    
      ll A=0;
      for(int j=0;j<v[i].size();j++) A=(A+dp[i][j])%p;
      dp[i][v[i].size()]=(dp[i][v[i].size()]+A)%p;
    
      for(int j=0;j<11;j++){
      
	if(v[i+1].size()==j) dp[i+1][j]=(dp[i+1][j]+(dp[i][j]*2)%p)%p;
	else dp[i+1][j]=(dp[i+1][j]+dp[i][j])%p;
      
      }
    
    }
  
    ll ans=0;
  
    for(int i=0;i<11;i++) ans=(ans+dp[n][i])%p;
  
    cout<<ans<<endl;
  } 
  return 0;
}