#include using namespace std; int main() { int a, b; cin >> a >> b; if (a > b) { if (3 * b > a) { cout << (a + b) % 2 << endl; } else { cout << a - 3 * b << endl; } } else { if (3 * a > b) { cout << (a + b) % 2 << endl; } else { cout << b - 3 * a << endl; } } }