Var a, b: word;
function NOD(x, y: integer):integer;
begin
repeat
if abs(x) > abs(y) then
x := x mod y
else
y := y mod x;
until (x = 0) or (y = 0);
NOD := abs(x + y);
end;
begin
write('a=');read(a);
write('b=');readln(b);
writeln('NOD(a,b)=', NOD(a, b));
end.