#coding:utf-8 def main(): A=map(int,raw_input().split()) if A[1]==1: return 'INF' cnt=0 for p in range(1,max(A)+1): B=[] for i in A: B.append(i%p) if len(set(B))==3: if max(B)==B[1] or min(B)==B[1]: cnt+=1 return cnt if __name__=='__main__': print main()