def find(a, b): while b != 0: a, b = b, a % b return a a, c = map(int, input().split()) result = find(a, c) print(result)