dbg = False

a, b = list(map(int, input().split()))

if a > b:
    x, y = a, b
else:
    x, y = b, a

divs = [1]
for i in range(1, int((y+1)/2)+1):
    gcd_tmp = int(y / i)
    if dbg: print('%d, %d' % (i, gcd_tmp))
    if i > gcd_tmp:
        break
    if y % i == 0:
        if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()
        elif x % i == 0:
            divs.append(i)

print(max(divs)) dbg = False dbg False a, b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b if a > b:
    x, y = a, b
else:
    x, y = b, a a > b a b x, y = a, b x a y b x, y = b, a x b y a divs = [1] divs [1] 1 for i in range(1, int((y+1)/2)+1):
    gcd_tmp = int(y / i)
    if dbg: print('%d, %d' % (i, gcd_tmp))
    if i > gcd_tmp:
        break
    if y % i == 0:
        if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()
        elif x % i == 0:
            divs.append(i) i range(1, int((y+1)/2)+1) range 1 int((y+1)/2)+1 int((y+1)/2) int (y+1)/2 y+1 y 1 2 1 gcd_tmp = int(y / i) gcd_tmp int(y / i) int y / i y i if dbg: print('%d, %d' % (i, gcd_tmp))
     dbg if i > gcd_tmp:
        break
     i > gcd_tmp i gcd_tmp break if y % i == 0:
        if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()
        elif x % i == 0:
            divs.append(i) y % i == 0 y % i y i 0 if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()
        elif x % i == 0:
            divs.append(i) x % gcd_tmp == 0 x % gcd_tmp x gcd_tmp 0 print(gcd_tmp) print gcd_tmp exit() exit elif x % i == 0:
            divs.append(i) x % i == 0 x % i x i 0 divs.append(i) divs.append divs append i print(max(divs)) print max(divs) max divs dbg = False False dbg y = b, a a y b = list(map(int, input().split())) list(map(int, input().split())) b x, y = b, a b x divs = [1] [1] divs a, b = list(map(int, input().split())) list(map(int, input().split())) a x, y = a, b a x y = a, b b y gcd_tmp = int(y / i) int(y / i) gcd_tmp
dbg = False

a, b = list(map(int, input().split()))

if a > b:
    x, y = a, b
else:
    x, y = b, a

divs = [1]
for i in range(1, int((y+1)/2)+1):
    gcd_tmp = int(y / i)
    if dbg: print('%d, %d' % (i, gcd_tmp))
    if i > gcd_tmp:
        break
    if y % i == 0:
        if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()
        elif x % i == 0:
            divs.append(i)

print(max(divs))