n,m=map(int,input().split()) count=0 if n==2 and n2 and m>2: print(count) break a=n//2 b=n-a if a%2 or b%2: print(-1) break n=a