var
a, b, c:integer;
begin
write('a = '); readln(a);
write('b = '); readln(b);
write('c = '); readln(c);
write('НОД(', a, ', ', b, ', ', c, ') = ');
while (a <> 0) and (b <> 0) do
if a >= b then
a := a mod b
else
b := b mod a;
a := a + b;
while (c <> 0) and (a <> 0) do
if a >= c then
a := a mod c
else
c := c mod a;
writeln(a + c);
end.