#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 (3 * b >= a) { cout << (a + b) % 2 << endl; } else { cout << 2 * b << endl; } }