#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

x, y = map(int, sys.stdin.readline().split())
print(gcd(x, y))
 import sys sys def gcd(x, y):
    while y:
        x, y = y, x % y
    return x gcd while y:
        x, y = y, x % y
     y x, y = y, x % y x y y x % y x y return x x x x y y x, y = map(int, sys.stdin.readline().split()) x map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split y print(gcd(x, y)) print gcd(x, y) gcd x y y = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) y x, y = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) x def gcd(x, y):
    while y:
        x, y = y, x % y
    return x def gcd(x, y):
    while y:
        x, y = y, x % y
    return x gcd
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

x, y = map(int, sys.stdin.readline().split())
print(gcd(x, y))

