#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<int,int>P;

int p;

class BIT{
public:
    int n; vector<int> bit;
    void add(int i,int x){
        i++;
        while(i < n) bit[i] = (bit[i]+x)%p, i += i & -i;
    }
    int sum(int i){
        i++;
        int s = 0;
        while(i > 0) s = (s+bit[i])%p, i -= i & -i;
        return s;
    }
    BIT(int sz){
        n = sz+1, bit.resize(n,0);
    }
};

int dp[100005];

int main()
{
    while(1){
        int a,b;
        cin >> a >> b >> p;
        if(a == 0) break;
        vector<string> s(b-a+1);
        int n = b-a+1;
        for(int i=a;i<=b;i++){
            string t;
            int nw = i;
            while(nw){
                t.push_back((char)('0'+nw%10));
                nw /= 10;
            }
            reverse(all(t));
            s[i-a] = t;
        }
        sort(all(s));
        vector<int> num(n);
        rep(i,n){
            dp[i] = 0, num[i] = stoi(s[i]);
        }
        BIT bt(n);
        rep(i,n){
            int res = bt.sum(num[i]-a);
            res = (res+1)%p;
            bt.add(num[i]-a,res);
        }
        cout << bt.sum(n-1) << "\n";
    }
}

