#include <bits/stdc++.h>
using namespace std;
long long c[33] = {8533824895, 4369023041, 6246905437, 6253595997, 6261859165,
                   4379596097, 8545195391, 31973120,   5359932369, 1753546555,
                   2732754382, 6470747678, 882671615,  1254829703, 2192389205,
                   12462605,   3051539536, 3802390309, 595890157,  2193723792,
                   910809452,  3401336238, 3769820759, 1067701411, 527048132,
                   3511002880, 3043217791, 7268642369, 1058285917, 3085511773,
                   493838941,  255747649,  4625435519};
int main() {
  int a, b;
  cin >> a >> b;
  long long d = c[a];
  for (int i = 0; i < b; i++) {
    d /= 2;
  }
  cout << d % 2 << endl;
  return 0;
}
