#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; ll ans = 0; if (n % 2 == 0) { ans = (ll) m * n; } else { int cnt = 0; for (int x = 30; x >= 0; --x) { if (m & (1 << x)) { ans += (ll) (n - 1) * (1 << x); if (cnt < n) ++cnt; } else { ans += (cnt / 2 * 2) * (1 << x); } } } cout << ans << '\n'; return 0; }