#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int a, b; cin >> a >> b; // x % a == b % x for (int x = 1; x <= 1e5; x++) { if (x % a == b % x) { cout << x << '\n'; break; } } return 0; }