program lcm; var a,b,n,p:int64; begin read(a,b); if a>b then begin p:=a; a:=b; b:=p; end; n:=0; while (b+n) mod (a+n)<>0 do n:=n+1; write(n); end.