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