def gcd (m, n): min = m if m > n : min = n for i in range (min, 0, -1): if m % i == 0 and n % i == 0: return i m, n = input().split() print (gcd (int(m), int(n)))