#include <iostream>
#include <cmath>

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 << pow(2, n + 3) - 3;
    if(m == 4)cout << pow(2, pow(4, n + 1)) - 3;
    if(m == 5 && n == 0)cout << 65533;

    return 0;
}