#include using namespace std; int main() { int A,B,a,b; cin >> A >> B >> a >> b; int aa=0,bb=0,i=0,j=0,check=0; while(true){ aa=A*i+a; while(true){ bb=B*j+b; if(aa==bb){ cout << aa << endl; return 0; } else if(aa