a,c=input().split() a,c=int(a),int(c) def x(m,n): if m<n: m,n=n,m if n==0: return m return x(n,m%n) res=x(a,c) print(res)