#include<bits/stdc++.h>
using namespace std;
#define ll long long
// #define mod 1000000007
ll mod,m;
ll f(ll a,ll n, ll mod){
ll res = a, ans =0;
while(n){
if(n%2) ans = (ans + res ) %mod;
res = (res + res)%mod;
n/=2;
}
return ans;
}
ll po(ll a,ll n){
ll res=a, ans=1;
while(n){
if(n%2) ans=f(ans,res,mod);
res=f(res,res,mod);
n/=2;
}
return ans;
}
ll po_thuong(ll a,ll n){
ll res=a, ans=1;
while(n){
if(n%2) ans=ans*res%mod;
res=res*res%mod;
n/=2;
}
return (ans+mod)%mod;
}
ll aka(ll p, ll alpha){
if(alpha==0) return 1;
if(alpha==1) return (p+1)%mod;
if(alpha%2==1) return (f(p,aka(p,alpha-1),mod)+1)%mod;
if(alpha%2==0) return (f((po(p,alpha/2)+1),((aka(p,alpha/2)-1+mod)%mod),mod)+1)%mod;
}
int main(){
// cout<<aka(2,1);
// 1+2+2^2+2^3
ll x,n,m;
cin>>x>>n>>m;
ll p,q,len;
mod = m;
len = to_string(x).size();
// cout<<len<<'\n';
p = po(10,len);
// cout<<p<<'\n';
q=x%mod;
// cout<<q<<'\n';
ll f1 = q;
// cout<<po(p,n-1)<<'\n';
// cout<<"thuong: "<<po_thuong(p,n-1)<<'\n';
ll ans = f(po(p,n-1),f1,mod);
// cout<<ans<<'\n';
ll ans1 = n>=2?f(q,aka(p,n-2),mod):0;
// cout<<ans1<<'\n';
ll ress = (ans+ans1)%mod;
cout<<ress;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcgCi8vICNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKbGwgbW9kLG07CmxsIGYobGwgYSxsbCBuLCBsbCBtb2QpewogIGxsIHJlcyA9IGEsIGFucyA9MDsKICB3aGlsZShuKXsKICAgIGlmKG4lMikgYW5zID0gKGFucyArIHJlcyApICVtb2Q7CiAgICByZXMgPSAocmVzICsgcmVzKSVtb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