#include using namespace std; int main() { int a, b; cin >> a >> b; cout << min((a + b) % 4, (100 - a - b) % 4) << endl; }