# coding: utf-8

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

n, m = map(int, input().split())

print(int(gcd(n, m))) def gcd(a, b):
    while b:
        a, b = b, a % b
    return a 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 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m print(int(gcd(n, m))) print int(gcd(n, m)) int gcd(n, m) gcd n m n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m def gcd(a, b):
    while b:
        a, b = b, a % b
    return a def gcd(a, b):
    while b:
        a, b = b, a % b
    return a gcd
# coding: utf-8

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

n, m = map(int, input().split())

print(int(gcd(n, m)))