#include<bits/stdc++.h> using namespace std; typedef long long ll; inline int read(ll &x){ int f=0;x=0;char ch=getchar(); for(;!isdigit(ch);ch=getchar())f|=(ch=='-'); for(;isdigit(ch);ch=getchar())x=x*10+ch-'0'; if(f)x=-x; } const ll A=23; const ll B=233; const ll C=2333; ll a,b,c,x; int main(){ ios::sync_with_stdio(false); read(a); read(b); read(c); x=(c==0?C:c); while(x%A!=a||x%B!=b){ x+=C; } cout<<x<<endl; return 0; }