A = [int(i) for i in input().strip().split(' ')] if(min(A) == A[1] or max(A) == A[1]): print('INF') exit(0) cnt = 0 for i in range(1, 1001): B = [j % i for j in A] if len(list(set(B))) == 3: if(min(B) == B[1] or max(B) == B[1]): cnt += 1 print(cnt)