def gcd(aa,bb):
    while bb!=0:
        r=bb
        bb=aa%bb
        aa=r
    return aa
a,b=map(int,raw_input().strip().split())
#print a,b
print gcd(a,b)
 def gcd(aa,bb):
    while bb!=0:
        r=bb
        bb=aa%bb
        aa=r
    return aa gcd while bb!=0:
        r=bb
        bb=aa%bb
        aa=r
     bb!=0 bb 0 r=bb r bb bb=aa%bb bb aa%bb aa bb aa=r aa r return aa aa aa aa bb bb a,b=map(int,raw_input().strip().split()) a map(int,raw_input().strip().split()) map int raw_input().strip().split() ().strip().split ().strip() ().strip () raw_input strip split b print gcd(a,b) gcd a b a,b=map(int,raw_input().strip().split()) map(int,raw_input().strip().split()) a def gcd(aa,bb):
    while bb!=0:
        r=bb
        bb=aa%bb
        aa=r
    return aa def gcd(aa,bb):
    while bb!=0:
        r=bb
        bb=aa%bb
        aa=r
    return aa gcd b=map(int,raw_input().strip().split()) map(int,raw_input().strip().split()) b
def gcd(aa,bb):
    while bb!=0:
        r=bb
        bb=aa%bb
        aa=r
    return aa
a,b=map(int,raw_input().strip().split())
#print a,b
print gcd(a,b)

