#include <bits/stdc++.h>
using namespace std;
int p,q,r;
bool check(int b,int x){
int i=0,a[1005]={0};
while(x){
a[++i]=x%b;
x/=b;
}
int xx=0;
for(int j=i;j>=1;j--){
xx+=a[j]*pow(10,(--i));
}
return xx==r;
}
int main()
{
cin>>p>>q>>r;
int pq=p*q;
for(int i=2;i<=16;i++){
if(check(i,pq)){
cout<<i<<endl;
return 0;
}
}
cout<<0<<endl;
return 0;
}
玄关!