#include using namespace std; using ll = long long; int main(void) { ll N, M; cin >> N >> M; if(N % 2 == 0) { cout << N * M << "\n"; return 0; } ll ans = 0, cnt = 0; for(int i = 29; i >= 0; --i) { if(M >> i & 1) { ans += (1LL << i) * (N - 1); ++cnt; } else { ans += (1LL << i) * (cnt / 2) * 2; } } cout << ans << "\n"; return 0; }