def GSD(x, y):
    while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0
x, y = map(int, input().split(' '))
print(GSD(x, y)) def GSD(x, y):
    while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0 GSD while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0 True x0 = max(x, y) x0 max(x, y) max x y y0 = min(x, y) y0 min(x, y) min x y if x0 % y0 == 0:
            return y0
         x0 % y0 == 0 x0 % y0 x0 y0 0 return y0 y0 x = x0 % y0 x x0 % y0 x0 y0 y = y0 y y0 x x y y x, y = map(int, input().split(' ')) x map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' y print(GSD(x, y)) print GSD(x, y) GSD x y def GSD(x, y):
    while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0 def GSD(x, y):
    while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0 GSD y = map(int, input().split(' ')) map(int, input().split(' ')) y x, y = map(int, input().split(' ')) map(int, input().split(' ')) x
def GSD(x, y):
    while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0
x, y = map(int, input().split(' '))
print(GSD(x, y))
