#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(x) (x).begin(), (x).end()
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define sz(x) (ll)((x).size())
#define fr first
#define sc second
#define pii pair<int, int>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))

int main()
{
    int x, y;
    cin >> x >> y;

    if (x == 0 and y == 0)
        cout << 0 << endl;

    else if (x == 0 and y == 1)
        cout << 2 << endl;

    else if (x == 1 and y == 0)
        cout << 2 << endl;

    else if (x == 1 and y == 1)
        cout << 1 << endl;

    else if (x == 0 and y == 2)
        cout << 1 << endl;

    else if (x == 2 and y == 0)
        cout << 1 << endl;

    else if (x == 1 and y == 2)
        cout << 0 << endl;

    else if (x == 2 and y == 1)
        cout << 0 << endl;

    else if (x == 2 and y == 2)
        cout << 2 << endl;

    return 0;
}
/**
    Lost Arrow (Aryan V S)
    Saturday 2021-03-13
**/

#ifdef LOST_IN_SPACE
#  if   __cplusplus > 201703LL
#    include "lost_pch1.h" // C++20
#  elif __cplusplus > 201402LL
#    include "lost_pch2.h" // C++17
#  else
#    include "lost_pch3.h" // C++14
#  endif
#else
#  include <bits/stdc++.h>
#endif

constexpr bool test_cases = false;

void solve () {
    int m, h;
    std::cin >> m >> h;
    std::cout << (h % m == 0 ? "Yes" : "No") << '\n';
}

int main () {

    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.precision(10);
    std::cerr.precision(10);
    std::cout << std::fixed << std::boolalpha;
    std::cerr << std::fixed << std::boolalpha;

    int32_t cases = 1;
    if (test_cases)
        std::cin >> cases;
    while (cases--)
        solve();

    return 0;
}

// g++.exe -Wall -Weffc++ -Wextra -pedantic -std=c++20 -g -D_GLIBCXX_DEBUG -DLOST_IN_SPACE -H

// Replace failing with learning
// Replace overthinking with action
// Replace blame with responsibility
// Replace toxic friends with mentors
// Replace complaining with gratitude
// Replace netflix marathons with sleep
// Replace fake influencers with inspiring creators
