""" """ import sys from sys import stdin import math A,B,C = map(int,stdin.readline().split()) if math.gcd(math.gcd(A,B),C) != 1: print ("INF") sys.exit() mov = max(A,B,C) dp = [False] * mov + [True] ans = 0 streak = 0 while True: if streak > mov: break dp.append(dp[-A] or dp[-B] or dp[-C]) if dp[-1] == True: streak += 1 else: streak = 0 ans += 1 print (ans)