is_kadomatsu = lambda x: (max(x) == x[1] or min(x) == x[1]) and not is_zero(x) is_zero = lambda x: x[0] == x[-1] an = list(map(int, input().split())) if is_zero(an): print(0) elif is_kadomatsu(an): print('INF') else: cnt = 0 for b in [list(map(lambda y: y % i, an)) for i in range(2, max(an) + 1)]: # print(b) if is_kadomatsu(b): cnt += 1 print(cnt)