#include <iostream>
using namespace std;
int main() {
    int m, n;
    cin >> n >> m;
    if(m == 0)cout << n + 1;
    if(m == 1)cout << n + 2;
    if(m == 2)cout << 2 * n + 3;
    if(m == 3)cout << (1 << n + 3) - 3;
    if(m == 4)cout << (1 << (1 << 2 * n + 2)) - 3;
    if(m == 5 && n == 0)cout << 65533;
    return 0;
}