import math A, B, C = map(int, input().split()) def gcd_three(a, b, c): return math.gcd(math.gcd(a, b), c) g = gcd_three(A, B, C) if g != 1: print("INF") else: if A == 1 or B == 1 or C == 1: print(0) else: m = min(A, B, C) max_limit = 10**6 dp = [False] * (max_limit + 1) dp[0] = True consecutive = 0 max_i = 0 found = False for i in range(1, max_limit + 1): can_form = False if i - A >= 0 and dp[i - A]: can_form = True if not can_form and i - B >= 0 and dp[i - B]: can_form = True if not can_form and i - C >= 0 and dp[i - C]: can_form = True if can_form: dp[i] = True consecutive += 1 if consecutive == m: max_i = i found = True break else: consecutive = 0 if not found: print("INF") else: count = 0 upper = max_i - m for i in range(1, upper + 1): if not dp[i]: count += 1 print(count)