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