#!/usr/bin/env python
# coding: utf-8

def gcd ( ax, ay):
    x = ax
    y = ay
    while (True):
        if x < y :
            tmp = x
            x = y
            y = tmp
        x=x %y
        if x == 0:
            return y
        elif x == 1:
            return 1



x,y = map(int, input().split())
print(gcd(x,y)) def gcd ( ax, ay):
    x = ax
    y = ay
    while (True):
        if x < y :
            tmp = x
            x = y
            y = tmp
        x=x %y
        if x == 0:
            return y
        elif x == 1:
            return 1 gcd x = ax x ax y = ay y ay while (True):
        if x < y :
            tmp = x
            x = y
            y = tmp
        x=x %y
        if x == 0:
            return y
        elif x == 1:
            return 1 True if x < y :
            tmp = x
            x = y
            y = tmp
         x < y x y tmp = x tmp x x = y x y y = tmp y tmp x=x %y x x %y x y if x == 0:
            return y
        elif x == 1:
            return 1 x == 0 x 0 return y y elif x == 1:
            return 1 x == 1 x 1 return 1 1 ax ax ay ay 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 y = map(int, input().split()) map(int, input().split()) y def gcd ( ax, ay):
    x = ax
    y = ay
    while (True):
        if x < y :
            tmp = x
            x = y
            y = tmp
        x=x %y
        if x == 0:
            return y
        elif x == 1:
            return 1 def gcd ( ax, ay):
    x = ax
    y = ay
    while (True):
        if x < y :
            tmp = x
            x = y
            y = tmp
        x=x %y
        if x == 0:
            return y
        elif x == 1:
            return 1 gcd x,y = map(int, input().split()) map(int, input().split()) x
#!/usr/bin/env python
# coding: utf-8

def gcd ( ax, ay):
    x = ax
    y = ay
    while (True):
        if x < y :
            tmp = x
            x = y
            y = tmp
        x=x %y
        if x == 0:
            return y
        elif x == 1:
            return 1



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