a = [int(i) for i in input().split()] res = 0 for i in range(1, max(a)+1): b = [e % i for e in a] if len(b) != len(set(b)): continue if b[1] == max(b) or b[1] == min(b): res += 1 b = [e % (max(a)+1) for e in a] if len(b) == len(set(b)) and (b[1] == max(b) or b[1] == min(b)): print("INF") else: print(res)