# -*- coding : utf-8 -*-

def gcd(num_a, num_b):
    if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

    if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b)

num_a, num_b = [int(x) for i, x in enumerate(input().split()) if i < 2]
print(gcd(num_a, num_b)) def gcd(num_a, num_b):
    if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

    if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b) gcd if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

     num_b == 0 num_b 0 return num_a num_a elif num_a == 0:
        return num_b

     num_a == 0 num_a 0 return num_b num_b if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b) num_a < num_b num_a num_b return gcd(num_a, num_b % num_a) gcd(num_a, num_b % num_a) gcd num_a num_b % num_a num_b num_a return gcd(num_b, num_a % num_b) gcd(num_b, num_a % num_b) gcd num_b num_a % num_b num_a num_b num_a num_a num_b num_b int(x) for i, x in enumerate(input().split()) if i < 2 for i, x in enumerate(input().split()) if i < 2 i x enumerate(input().split()) enumerate input().split() ().split () input split i < 2 i 2 if i < 2 int(x) int x num_a, num_b = [int(x) for i, x in enumerate(input().split()) if i < 2] num_a [int(x) for i, x in enumerate(input().split()) if i < 2] num_b print(gcd(num_a, num_b)) print gcd(num_a, num_b) gcd num_a num_b num_a, num_b = [int(x) for i, x in enumerate(input().split()) if i < 2] [int(x) for i, x in enumerate(input().split()) if i < 2] num_a num_b = [int(x) for i, x in enumerate(input().split()) if i < 2] [int(x) for i, x in enumerate(input().split()) if i < 2] num_b def gcd(num_a, num_b):
    if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

    if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b) def gcd(num_a, num_b):
    if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

    if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b) gcd
# -*- coding : utf-8 -*-

def gcd(num_a, num_b):
    if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

    if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b)

num_a, num_b = [int(x) for i, x in enumerate(input().split()) if i < 2]
print(gcd(num_a, num_b))