def gcd(x, y):
    '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????'''

    if x < y:
        tmp = x
        x = y
        y = tmp

    while y > 0:
        tmp = x % y
        x = y
        y = tmp

    return x
    
def test():
    '''??? input =
    147 105
    ->
    21'''

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

    result = gcd(x, y)
    print(result)

if __name__ == '__main__':
    test() def gcd(x, y):
    '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????'''

    if x < y:
        tmp = x
        x = y
        y = tmp

    while y > 0:
        tmp = x % y
        x = y
        y = tmp

    return x
     gcd '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????''' 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 while y > 0:
        tmp = x % y
        x = y
        y = tmp

     y > 0 y 0 tmp = x % y tmp x % y x y x = y x y y = tmp y tmp return x x x x y y def test():
    '''??? input =
    147 105
    ->
    21'''

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

    result = gcd(x, y)
    print(result) test '''??? input =
    147 105
    ->
    21''' x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y result = gcd(x, y) result gcd(x, y) gcd x y print(result) print result if __name__ == '__main__':
    test() __name__ == '__main__' __name__ '__main__' test() test def test():
    '''??? input =
    147 105
    ->
    21'''

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

    result = gcd(x, y)
    print(result) def test():
    '''??? input =
    147 105
    ->
    21'''

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

    result = gcd(x, y)
    print(result) test def gcd(x, y):
    '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????'''

    if x < y:
        tmp = x
        x = y
        y = tmp

    while y > 0:
        tmp = x % y
        x = y
        y = tmp

    return x
     def gcd(x, y):
    '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????'''

    if x < y:
        tmp = x
        x = y
        y = tmp

    while y > 0:
        tmp = x % y
        x = y
        y = tmp

    return x
     gcd
def gcd(x, y):
    '''??????????????????????????????
    x>=y?????¨??????gcd(x, y)??¨gcd(y, x%y)?????????????????¨????????¨??????'''

    if x < y:
        tmp = x
        x = y
        y = tmp

    while y > 0:
        tmp = x % y
        x = y
        y = tmp

    return x
    
def test():
    '''??? input =
    147 105
    ->
    21'''

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

    result = gcd(x, y)
    print(result)

if __name__ == '__main__':
    test()