var a,b:integer; begin readln(a,b); while a<>b do begin if a>b then a:=a-b; if a<b then b:=b-a; end; writeln(a); readln; end.