from collections import defaultdict

def gcd(x,y):
    if max(x,y) % min(x,y) == 0 : return min(x,y)
    else : return gcd(min(x,y) ,max(x,y)%min(x,y))

if __name__ == '__main__' :
        a,b = [int(i) for i in input().split(" ")]
        print(gcd(a,b)) from collections import defaultdict def gcd(x,y):
    if max(x,y) % min(x,y) == 0 : return min(x,y)
    else : return gcd(min(x,y) ,max(x,y)%min(x,y)) gcd if max(x,y) % min(x,y) == 0 : return min(x,y)
    else : return gcd(min(x,y) ,max(x,y)%min(x,y)) max(x,y) % min(x,y) == 0 max(x,y) % min(x,y) max(x,y) max x y min(x,y) min x y 0 x x y y if __name__ == '__main__' :
        a,b = [int(i) for i in input().split(" ")]
        print(gcd(a,b)) __name__ == '__main__' __name__ '__main__' int(i) for i in input().split(" ") for i in input().split(" ") i input().split(" ") ().split () input split " " for i in input().split(" ") int(i) int i a,b = [int(i) for i in input().split(" ")] a [int(i) for i in input().split(" ")] b print(gcd(a,b)) print gcd(a,b) gcd a b b = [int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] b def gcd(x,y):
    if max(x,y) % min(x,y) == 0 : return min(x,y)
    else : return gcd(min(x,y) ,max(x,y)%min(x,y)) def gcd(x,y):
    if max(x,y) % min(x,y) == 0 : return min(x,y)
    else : return gcd(min(x,y) ,max(x,y)%min(x,y)) gcd a,b = [int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] a
from collections import defaultdict

def gcd(x,y):
    if max(x,y) % min(x,y) == 0 : return min(x,y)
    else : return gcd(min(x,y) ,max(x,y)%min(x,y))

if __name__ == '__main__' :
        a,b = [int(i) for i in input().split(" ")]
        print(gcd(a,b))
