using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace tes { class contest { static void Main(string[] args) { var num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); Console.WriteLine(gcd(num[0],num[1])); } static int gcd(int a, int b) { return (a % b == 0) ? a : gcd(a % b, a); } } }