# coding: UTF-8
def euclidean_algorithm(x,y):
    if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p

num1,num2 = raw_input().split()
maximam = euclidean_algorithm(int(num1), int(num2))
print(maximam)
 def euclidean_algorithm(x,y):
    if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p euclidean_algorithm if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p x > y x y p = y p y r = x%y r x%y x y while r != 0:
            a = p
            b = r
            p = b
            r = a%b
         r != 0 r 0 a = p a p b = r b r p = b p b r = a%b r a%b a b return p p elif x == y:
        return x
     x == y x y return x x elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p x < y x y p = x p x r = y%x r y%x y x while r != 0:
            a = p
            b = r
            p = b
            r = a%b
         r != 0 r 0 a = p a p b = r b r p = b p b r = a%b r a%b a b return p p x x y y num1,num2 = raw_input().split() num1 raw_input().split() ().split () raw_input split num2 maximam = euclidean_algorithm(int(num1), int(num2)) maximam euclidean_algorithm(int(num1), int(num2)) euclidean_algorithm int(num1) int num1 int(num2) int num2 print(maximam) print maximam def euclidean_algorithm(x,y):
    if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p def euclidean_algorithm(x,y):
    if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p euclidean_algorithm maximam = euclidean_algorithm(int(num1), int(num2)) euclidean_algorithm(int(num1), int(num2)) maximam num1,num2 = raw_input().split() raw_input().split() num1 num2 = raw_input().split() raw_input().split() num2
# coding: UTF-8
def euclidean_algorithm(x,y):
    if x > y:
        p = y
        r = x%y
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p
    elif x == y:
        return x
    elif x < y:
        p = x
        r = y%x
        while r != 0:
            a = p
            b = r
            p = b
            r = a%b
        return p

num1,num2 = raw_input().split()
maximam = euclidean_algorithm(int(num1), int(num2))
print(maximam)

