import sys
import math

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

x, y = map(int, raw_input().split())
print gcd(min(x, y), max(x, y)) import sys sys import math math def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y) gcd if y == 0:
        return x
     y == 0 y 0 return x x return gcd(y, x%y) gcd(y, x%y) gcd y x%y x y x x y y x, y = map(int, raw_input().split()) x map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split y print gcd(min(x, y), max(x, y)) gcd min(x, y) min x y max(x, y) max x y x, y = map(int, raw_input().split()) map(int, raw_input().split()) x y = map(int, raw_input().split()) map(int, raw_input().split()) y def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y) def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y) gcd
import sys
import math

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

x, y = map(int, raw_input().split())
print gcd(min(x, y), max(x, y))