def is_kadomatsu(lst): if len(set(lst)) != 3: return False return min(lst) == lst[1] or max(lst) == lst[1] lst = list(map(int,input().split())) i = 2 cnt = 0 t_chain = 0 f_chain = 0 while True: if is_kadomatsu([x % i for x in lst]): cnt+=1 t_chain+=1 f_chain = 0 else: f_chain+=1 t_chain = 0 if t_chain >= 100 or f_chain >= 100: break i+=1 if t_chain >= 100: ans = "INF" else: ans = cnt print(ans)