N, M = map(int, input().split()) if N%2 == 0: print(M*N) else: L = M ^ (2**M.bit_length()-1) ans = M*(N-1) + 2*L*(N//2 - 1) print(ans)