#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sst stringstream
#define sz size()
#define vc vector
typedef vc<int> vi;
typedef vc<ll> vl;
typedef vc<string> vs;

#define MAXN (1<<17)

ll bit[MAXN+1],n=MAXN;

void init(){
	fill(bit,bit+n+1,0);
}

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

void add(int i,ll x){
	while(i<=n){
		bit[i]+=x;
		i+=i&-i;
	}
}

int A,B,P,a[100010],N;
string s[100010];

bool comp(int a,int b){
	return s[a-A]<s[b-A];
}

int main(){
	while(cin>>A>>B>>P && A){
		init();
		N=B-A+1;
		rep2(i,A,B+1){
			a[i-A]=i;
			sst ss;
			ss<<i;
			s[i-A]=ss.str();
		}
		sort(a,a+N,comp);
		ll ans=0;
		rep(i,N){
			ll res=(1+sum(a[i]-A+1))%P;
			ans=(ans+res)%P;
			add(a[i]-A+1,res);
		}
		cout<<ans<<endl;
	}
}