int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
if (b>a)
{
int x = a;
a = b;
b = x;
}
while (a%b!=0)
{
int n = b;
b = a % b;
a = n;
}
Console.WriteLine(b);