def gcd(X,Y):
    x = X
    y = Y
    if y > x:
        x,y = y,x
    while x % y:
        x,y = y,x%y
    return y

number = [int(i) for i in input().split()]
print(gcd(number[0],number[1])) def gcd(X,Y):
    x = X
    y = Y
    if y > x:
        x,y = y,x
    while x % y:
        x,y = y,x%y
    return y gcd x = X x X y = Y y Y if y > x:
        x,y = y,x
     y > x y x x,y = y,x x y y x while x % y:
        x,y = y,x%y
     x % y x y x,y = y,x%y x y y x%y x y return y y 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 number = [int(i) for i in input().split()] number [int(i) for i in input().split()] print(gcd(number[0],number[1])) print gcd(number[0],number[1]) gcd number[0] number 0 number[1] number 1 def gcd(X,Y):
    x = X
    y = Y
    if y > x:
        x,y = y,x
    while x % y:
        x,y = y,x%y
    return y def gcd(X,Y):
    x = X
    y = Y
    if y > x:
        x,y = y,x
    while x % y:
        x,y = y,x%y
    return y gcd number = [int(i) for i in input().split()] [int(i) for i in input().split()] number
def gcd(X,Y):
    x = X
    y = Y
    if y > x:
        x,y = y,x
    while x % y:
        x,y = y,x%y
    return y

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