import sys input = sys.stdin.readline from math import gcd N,M=list(map(int,input().split())) print(gcd(N,M))