A, B, C = map(int, input().split()) M = 5000 M2 = M * M dp = [0] * M2 a = 0 while a < M2: b = 0 if dp[a]: break while a + b < M2: c = 0 if dp[a + b]: break while a + b + c < M2: if dp[a + b + c]: break else: dp[a + b + c] = 1 c += C b += B a += A if 0 in dp[M2//2:]: print("INF") else: print(dp.count(0))