#include using namespace std; #define int long long typedef pair P; int INF = 3e18+7; int mod = 1e9+7; int dx[] = {1, 0,-1, 0, 1, 1,-1,-1}; int dy[] = {0, 1, 0,-1, 1,-1, 1,-1}; int gcd(int X,int Y) { if(X%Y == 0) { return Y; } else { return gcd(Y,X%Y); } } signed main() { int A,B,C; cin >> A >> B >> C; if(gcd(gcd(A,B),C) != 1) { cout << "INF" << endl; return 0; } int mn = INF; if(gcd(A,B) == 1) { mn = (A-1)*(B-1); } if(gcd(B,C) == 1) { mn = min(mn,(B-1)*(C-1)); } if(gcd(A,C) == 1) { mn = min(mn,(A-1)*(C-1)); } setst; for(int i = 0; i <= 2000; i++) { for(int j = 0; j <= 2000 && A*i+B*j <= mn; j++) { for(int k = 0; k <= 2000 && A*i+B*j+C*k <= mn; k++) { st.insert(A*i+B*j+C*k); } } } cout << mn-st.size()+1 << endl; }