from math import gcd print(gcd(int(input()), int(input())))