A = list(map(int, input().split())) if (min(A) == A[1] or max(A) == A[1]) and len(list(set(A))) == 3: print("INF") exit() res = 0 for i in range(1, max(A) + 1): B = [a % i for a in A] if (min(B) == B[1] or max(B) == B[1]) and len(list(set(B))) == 3: res += 1 print(res)