#include #if __has_include("./debug.cpp") #include "./debug.cpp" #else #define debug(...) #define print_line #endif using namespace std; using ll = long long; int main() { int A, B, a, b; cin >> A >> B >> a >> b; for (int i = 0; i <= 9000000; i++) { if (i % A == a && i % B == b) { cout << i << endl; ; return 0; } } }