#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int a,b,p;
  while(cin>>a>>b>>p,a){
    int l=b-a+1;

    vector<int> dp(l,0);
    map<int, int> sm;
    for(int i=a;i<=b;i++){
      sm[i]=0;
      dp[i-a]=1;

      string s=to_string(i);
      if(s.size()==to_string(i-1).size()){
        sm[i]+=sm[i-1];
        sm[i]%=p;

        dp[i-a]+=sm[i-1];
        dp[i-a]%=p;
      }

      while(s.size()>1){
        s.pop_back();
        dp[i-a]+=sm[stoll(s)];
        dp[i-a]%=p;
      }

      sm[i]+=dp[i-a];
      sm[i]%=p;
    }

    int ans=0;
    for(int d:dp) ans+=d,ans%=p;
    cout<<ans<<endl;
  }
  return 0;
}

