#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll a,b,p;

ll solve() {
	ll n=b-a+1;
	vector<ll> dp(n,1);
	unordered_map<ll,ll> preff;
	ll sum=0;
	for(ll i=n-1; i>=0; i--) {
		ll tmp1=a+i;
		string tmp2=to_string(tmp1);
		dp[i]+=sum;
		string buf="";
		REP(j,tmp2.size()) {
			for(char c='0'; c<tmp2[j]; c++) {
				if(preff.count(stol(buf+c))) {
					dp[i]-=preff[stol(buf+c)];
				}
			}
			buf+=tmp2[j];
		}
		dp[i]=(dp[i]%p+p)%p;
		while(tmp1>0) {
			preff[tmp1]+=dp[i];
			preff[tmp1]%=p;
			tmp1/=10;
		}
		sum+=dp[i];
		sum%=p;
	}
	return sum;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		cin>>a>>b>>p;
		if(a==0&&b==0&&p==0) break;
		cout<<solve()<<endl;
	}
}

