import math a,b,c = map(int,input().split()) if math.gcd(a,math.gcd(b,c)) != 1: print("INF") exit() M = 4*10**6+5 dp = [0]*M dp[0] = 1 for i in range(3): for j in range(M): if j+a < M: dp[j+a] = max(dp[j],dp[j+a]) a,b,c = b,c,a print(M-sum(dp))