import sys

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

# print(gcd(54, 20))
# print(gcd(147, 105))

input = sys.stdin.readline()
input = input.split(" ")
input = [int(i) for i in input]

print(gcd(input[0], input[1])) import sys sys def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

# print(gcd(54, 20))
# print(gcd(147, 105)) gcd while b:
        a, b = b, a%b
     b a, b = b, a%b a b b a%b a b return a a a a b b input = sys.stdin.readline() input sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline input = input.split(" ") input input.split(" ") input.split input split " " int(i) for i in input for i in input i input for i in input int(i) int i input = [int(i) for i in input] input [int(i) for i in input] print(gcd(input[0], input[1])) print gcd(input[0], input[1]) gcd input[0] input 0 input[1] input 1 input = input.split(" ") input.split(" ") input input = sys.stdin.readline() sys.stdin.readline() input def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

# print(gcd(54, 20))
# print(gcd(147, 105)) def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

# print(gcd(54, 20))
# print(gcd(147, 105)) gcd input = [int(i) for i in input] [int(i) for i in input] input
import sys

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

# print(gcd(54, 20))
# print(gcd(147, 105))

input = sys.stdin.readline()
input = input.split(" ")
input = [int(i) for i in input]

print(gcd(input[0], input[1]))