using System;
public class Program
{
static long NOD (int a, int b)
{if (a==b) return a;
else if (a>b) return NOD(a-b,b);
else {return NOD(a,b-a);}
}
public static void Main()
int a=int.Parse(Console.ReadLine());
int b=int.Parse(Console.ReadLine());
Console.WriteLine(NOD (a,b));