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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<string, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define MAX_N 100010

ll p;

struct BIT{
  ll bit[MAX_N];

  void init(){
    memset(bit,0,sizeof(bit));
  }

  ll sum(int i){
    ll s=0;
    while(i>0){
      s=(s+bit[i])%p;
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    while(i<=MAX_N){
      bit[i]=(bit[i]+v)%p;
      i+=i&-i;
    }
  }
};

ll a,b,n;
ll idx[100010];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>a>>b>>p;
    if(a==0&&b==0&&p==0)break;
    vector<P> ss;
    n=b-a+1;
    ss.resize(n);
    rep(i,n){
      ss[i]=P(to_string(i+a),i);
    }
    sort(all(ss));
    rep(i,n){
      idx[ss[i].se]=i;
    }
    BIT dp;
    dp.init();
    rep(i,n){
      ll tmp=dp.sum(idx[i]+1)%p;
      dp.add(idx[i]+1,(tmp+1)%p);
    }
    cout<<dp.sum(n+1)%p<<endl;
  }
	return 0;
}