N, M = map(int, input().split()) if N%2 == 0: print(N*M) exit() c = 0 ans = 0 for b in range(29, -1, -1): if M>>b&1: ans += (N-1) * (1<