#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, m; cin >> n >> m; if(n % 2 == 0){ cout << n * m << '\n'; return 0; } ll ans = 0; int g = __lg(m), d = 0; for(int i = g; i >= 0; i--){ if(m >> i & 1){ ans += (n - 1) * (1ll << i); d++; }else{ ans += ((d / 2) * 2) * (1ll << i); } } cout << ans << '\n'; }