l = list(map(int,input().split())) def calc(p): s = [i % p for i in l] ss =set(s) if len(ss) < 3:return False if max(s) == s[1] or min(s) == s[1]: return True else: return False ans = 0 if calc(1001): print('INF') else: for p in range(1,1001): if calc(p): ans += 1 print(ans)