var S, K, A, B, N, rez:longint;
begin
readln (S, K, A, B);
if s*a=b then writeln (s*k)
else
begin
n:=1;
while n<1001 do
begin
if (abs(s*a-b)) mod n =0 then
begin
rez:=((b-s*a) div n) +s*k;
if (rez>=0) and (a>n*k) then
begin
writeln (rez);
halt;
end;
end;
inc (n);
end;
if n=1001 then writeln (-1);
end;
end.
dmFyIFMsIEssIEEsIEIsIE4sIHJlejpsb25naW50OwpiZWdpbgogICAgcmVhZGxuIChTLCBLLCBBLCBCKTsKICAgIGlmIHMqYT1iIHRoZW4gd3JpdGVsbiAocyprKQogICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgICAgICAgICBuOj0xOwogICAgICAgICAgICAgICAgICAgICAgd2hpbGUgbjwxMDAxIGRvCiAgICAgICAgICAgICAgICAgICAgICBiZWdpbgogICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWJzKHMqYS1iKSkgbW9kIG4gPTAgdGhlbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlejo9KChiLXMqYSkgZGl2IG4pICtzKms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlej49MCkgYW5kIChhPm4qaykgdGhlbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZWxuIChyZXopOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jIChuKTsKICAgICAgICAgICAgICAgICAgICAgIGVuZDsKICAgICAgICAgICAgICAgICAgICAgIGlmIG49MTAwMSB0aGVuIHdyaXRlbG4gKC0xKTsKICAgICAgICAgICAgICAgICBlbmQ7CmVuZC4=