#include <bits/stdc++.h>
using namespace std;
void MAKEIT() {
  int A, B;
  scanf("%d %d", &A, &B);
  int Total[3][7] = {
      {0, 1, 2, 2, 1, 0, 0}, {1, 0, 0, 1, 2, 2, 1}, {2, 2, 1, 0, 0, 1, 2}};
  int MOD = A % 6;
  for (int i = 0; i < 3; i++) {
    if (B == Total[i][MOD]) {
      printf("%d\n", i);
    }
  }
}
int main() {
  MAKEIT();
  return 0;
}
