A,B,a,b = map(int, input().split()) M = A*B for i in range(B): tmp = A*i+a if tmp%B==b: print(tmp)