N,K = map(int,input().split()) ans = c = 0 R = N - K while(R or K): a = R & 1 b = K & 1 if(a + b + c >= 2): ans += 1 c = 1 else: c = 0 R >>= 1 K >>= 1 print(ans)