import math # Read input N, M = map(int, input().split()) # Compute GCD gcd = math.gcd(N, M) # Output the result print(gcd)