#include<stdio.h>
#include<math.h>
int checkBinary(int n)
{
int B,max=-1;
while(n)
{
int ge;
ge=n%10;
if(max<ge)
{
max=ge;
}
n/=10;
}
for(B=2;B<=16;B++)
{
if(max<=2){
return 2;
}
if(B==max){
return B;
}
}
}
int getBinary(int n,int B)
{
int answer=0,count=0;
while(n)
{
int ge=n%10;
n/=10;
answer+=(int)ge*pow(B*1.0,count*1.0);
count++;
}
return answer;
}
int binary(int p,int q,int r)
{
int B,p1,q1,r1,s=0,max,B1,B2,B3;
B1=checkBinary(p);
B2=checkBinary(q);
B3=checkBinary(r);
max=B1;
if(B2>max){
max=B2;
}
if(B3>max){
max=B3;
}
for(B=max+1;B<=16;B++)
{
p1=getBinary(p,B);
q1=getBinary(q,B);
r1=getBinary(r,B);
if(p1*q1==r1)
{s++;
break;}
}
if(s!=0){
return B;
}else{
return 0;
}
}
int main()
{
int p,q,r;
scanf("%d%d%d",&p,&q,&r);
int result=binary(p,q,r);
printf("%d",result);
return 0;
}