#coding:utf-8
#1_1_B
def gcd(x, y):
    while x%y != 0:
        x, y = y, x%y
    return y

x, y = map(int, input().split())
print(gcd(x, y)) def gcd(x, y):
    while x%y != 0:
        x, y = y, x%y
    return y gcd while x%y != 0:
        x, y = y, x%y
     x%y != 0 x%y x y 0 x, y = y, x%y x y y x%y x y return y y x x y y x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y print(gcd(x, y)) print gcd(x, y) gcd x y x, y = map(int, input().split()) map(int, input().split()) x def gcd(x, y):
    while x%y != 0:
        x, y = y, x%y
    return y def gcd(x, y):
    while x%y != 0:
        x, y = y, x%y
    return y gcd y = map(int, input().split()) map(int, input().split()) y
#coding:utf-8
#1_1_B
def gcd(x, y):
    while x%y != 0:
        x, y = y, x%y
    return y

x, y = map(int, input().split())
print(gcd(x, y))