import math def compute_gcd(a, b, c): return math.gcd(a, math.gcd(b, c)) A, B, C = map(int, input().split()) d = compute_gcd(A, B, C) if d != 1: print("INF") else: m = min(A, B, C) # Use a maximum size to avoid memory issues. 1e6 is chosen based on problem constraints max_n = 10**6 dp = [False] * (max_n + 1) dp[0] = True # base case: 0 can be formed consecutive = 0 result = 0 for i in range(1, max_n + 1): # Check if current i can be formed by any of the coins can_form = False if i >= A and dp[i - A]: can_form = True if not can_form and i >= B and dp[i - B]: can_form = True if not can_form and i >= C and dp[i - C]: can_form = True dp[i] = can_form if can_form: consecutive += 1 if consecutive >= m: break # All subsequent numbers can be formed else: consecutive = 0 result += 1 # Count numbers that cannot be formed print(result)