#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cmath>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define MAX 1100000

using namespace std;

typedef long long ll;

ll A,B,MOD;
ll dp[MAX];

inline
int toIndex(ll a){ return a-A+1; }

int main()
{
  while(cin >> A >> B >> MOD,A|B|MOD)
    {
      ll range = B-A+5;
      rep(i,range)dp[i] = 0;
      dp[1] = 1;//1-indexed
      dp[toIndex(B+1)] = -1;

      REP(cur,A,B+1)
	{
	  if(cur != A)dp[toIndex(cur)] = (dp[toIndex(cur)] + dp[toIndex(cur-1)]) % MOD;
	  ll sp = cur;
	  while(sp <= B)
	    {
	      int digit = (int)log10(sp) + 1;
	      ll p10 = 1LL;
	      rep(i,digit)p10 *= 10LL;
	      ll nsp = (sp == cur?cur+1LL:sp);
	      p10 = min(p10,B+1);

	      dp[toIndex(nsp)]  = (dp[toIndex(nsp)]  + dp[toIndex(cur)]) % MOD;
	      dp[toIndex(p10)] = (dp[toIndex(p10)] + MOD - dp[toIndex(cur)]) % MOD;
	      sp = sp*10;
	    }

	}

      ll ans = 0;
      REP(i,A,B+1)ans = (dp[toIndex(i)] + ans) % MOD;

      cout << ans << endl;

    }
  return 0;
}