program c; procedure check(a, b, c: longint; k: byte); var pretykac: longint; i: longint; sumx: longint; ok: boolean; begin pretykac := 1 shl k; ok := false; for i:=0 to pretykac do begin sumx := b + pretykac*i - a; if (sumx>=0) and ((sumx mod c)=0) then begin writeln(sumx div c); { writeln('sumx: ', sumx); writeln('pretykac: ', pretykac); writeln('i: ', i); writeln('c: ', c); } ok := true; end; if ok then break; end; if not(ok) then writeln('FOREVER'); end; var a, b, c, k: longint; begin while true do begin readln(a, b, c, k); if (a=0) and (b=0) and (c=0) and (k=0) then break; check(a, b, c, k); end; end.