def calc_gcd(a,b):
    if a < b:
        a,b=b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b)

x,y=map(int,input().split())
print("%d"%(calc_gcd(x,y)))
 def calc_gcd(a,b):
    if a < b:
        a,b=b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b) calc_gcd if a < b:
        a,b=b,a
     a < b a b a,b=b,a a b b a if b == 0:
        return a
     b == 0 b 0 return a a return calc_gcd(b,a%b) calc_gcd(b,a%b) calc_gcd b a%b a b a a b b x,y=map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split y print("%d"%(calc_gcd(x,y))) print "%d"%(calc_gcd(x,y)) "%d" calc_gcd(x,y) calc_gcd x y x,y=map(int,input().split()) map(int,input().split()) x y=map(int,input().split()) map(int,input().split()) y def calc_gcd(a,b):
    if a < b:
        a,b=b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b) def calc_gcd(a,b):
    if a < b:
        a,b=b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b) calc_gcd
def calc_gcd(a,b):
    if a < b:
        a,b=b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b)

x,y=map(int,input().split())
print("%d"%(calc_gcd(x,y)))

