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