#include <bits/stdc++.h>

using namespace std;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int x, y;
    cin >> x >> y;
    vector<set<int>> st(4);
    for (int i = 0; i < 12; i++) {
        st[i % 4].insert(i);
    }
    for (int i = 0; i < 4; i++) {
        if (st[i].count(x) && st[i].count(y)) {
            st[i].erase(x);
            st[i].erase(y);
            cout << *st[i].begin() << endl;
            return 0;
        }
    }
}