def GCD(x,y):

    if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

    if(not(w == 0)):
        return GCD(z,w)
    else:
        return z

A = [int(i) for i in input().split()]
print(GCD(A[0],A[1]))

"""実行結果

100 55
5



66 77
11

"""
 def GCD(x,y):

    if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

    if(not(w == 0)):
        return GCD(z,w)
    else:
        return z GCD if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

     x >= y x y z = y z y w = x%y w x%y x y z = x z x w = y%x w y%x y x if(not(w == 0)):
        return GCD(z,w)
    else:
        return z not(w == 0) w == 0 w 0 return GCD(z,w) GCD(z,w) GCD z w return z z x x y y int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A = [int(i) for i in input().split()] A [int(i) for i in input().split()] print(GCD(A[0],A[1])) print GCD(A[0],A[1]) GCD A[0] A 0 A[1] A 1 """実行結果

100 55
5



66 77
11

""" A = [int(i) for i in input().split()] [int(i) for i in input().split()] A def GCD(x,y):

    if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

    if(not(w == 0)):
        return GCD(z,w)
    else:
        return z def GCD(x,y):

    if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

    if(not(w == 0)):
        return GCD(z,w)
    else:
        return z GCD
def GCD(x,y):

    if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

    if(not(w == 0)):
        return GCD(z,w)
    else:
        return z

A = [int(i) for i in input().split()]
print(GCD(A[0],A[1]))

"""実行結果

100 55
5



66 77
11

"""

