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

typedef long long ll;
ll A, B, P;

// 1-indexed
class BIT{
private:
    vector<ll> bit;
    
public:
    BIT(int n){
        bit.resize(n+1);
    }
    
    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 <= bit.size()){
            bit[i] = (bit[i] + v) % P;
            i += i&-i;
        }
    }
};

string ltos(ll a){
    string res = "";
    while(a){
        res += a%10 + '0';
        a /= 10;
    }
    reverse(res.begin(), res.end());
    return res;
}

void solve(){
    int D = B - A + 1;
    
    vector<pair<string, int>> vec;
    for(ll i=0; i<D; i++)
        vec.push_back(make_pair(ltos(A+i), i));
    sort(vec.begin(), vec.end());
    
    vector<int> lexorders(D);
    for(int i=0; i<D; i++)
        lexorders[vec[i].second] = i;
    
    vector<ll> dp(D);
    ll ans = 0;
    
    BIT bit = BIT(D);
    for(int i=0; i<D; i++){
        dp[i] = (1 + bit.sum(lexorders[i])) % P;
        ans = (ans + dp[i]) % P;
        bit.add(lexorders[i]+1, dp[i]);
    }
    cout << ans << endl;
}

int main(){
    while(cin >> A >> B >> P, A|B|P)
        solve();
    
    return 0;
}