#include <iostream>
#include <math.h>
#include <algorithm>
#define SIZE 30
using namespace std;
long int zhuanhuan(int x,int b){
int a[SIZE];
int i=0;
while(x>=10){
a[i]=x%10;
x/=10;
i++;
}
a[i]=x;
long int sum=0;
for(int j=0;j<SIZE;j++){
if(a[j]==0){
continue;
}
sum+=pow(b,j)*a[j];
}
return sum;
}
int getmax(int x){
int maxx=0;
while(x>=10){
if(x%10>=maxx){
maxx=x%10;
}
x/=10;
}
if(x>=maxx){
return x;
}
return maxx;
}
int main(){
int p,q,r;
cin>>p>>q>>r;
int k=max({getmax(p),getmax(q),getmax(r)})+1;
for(int b=k;b<=16;b++){
if(zhuanhuan(p,b)*zhuanhuan(q,b)==zhuanhuan(r,b)){
cout<<b;
return 0;
}
}
cout<<"0";
}