from collections import defaultdict A,B,a,b=map(int,input().split()) d=defaultdict(int) for i in range(a, A*B+1, A ): d[i] += 1 for i in range(b, A*B+1, B ): d[i] += 1 ans=99999999 for k in d: ans=min(ans, k if d[k] ==2 else 99999999) print(ans)