#include using namespace std; int main() { int x = 1; int A, B; cin >> A >> B; while(x%A!=B%x) { x = x + 1; } cout << x << endl; }