N,M=map(int,input().split()) if N%2==0: print(N*M) else: ans=M*(N-2) tmp=int("0b0"+"1"*len(bin(M)[3:]),2) ans+=tmp ans+=M^tmp print(ans)