d = map(int,raw_input().split()) a = d[0];b = d[1] def gcd(x,y): return x if y == 0 else gcd(y, x % y) print gcd(a,b)