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