import math
def div(x, y): #x>y
    A = 1
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0 and y % i == 0:
            A = max(A, i)
        j = int(x/i)
        if x % j == 0 and y % j == 0:
            A = max(A, j)
    return A
x, y = map(int, input().split(" "))
print(div(x,y))


 import math math def div(x, y): #x>y
    A = 1
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0 and y % i == 0:
            A = max(A, i)
        j = int(x/i)
        if x % j == 0 and y % j == 0:
            A = max(A, j)
    return A div A = 1 A 1 for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0 and y % i == 0:
            A = max(A, i)
        j = int(x/i)
        if x % j == 0 and y % j == 0:
            A = max(A, j)
     i range(1, int(math.sqrt(x))+1) range 1 int(math.sqrt(x))+1 int(math.sqrt(x)) int math.sqrt(x) math.sqrt math sqrt x 1 if x % i == 0 and y % i == 0:
            A = max(A, i)
         x % i == 0 and y % i == 0 x % i == 0 x % i x i 0 y % i == 0 y % i y i 0 A = max(A, i) A max(A, i) max A i j = int(x/i) j int(x/i) int x/i x i if x % j == 0 and y % j == 0:
            A = max(A, j)
     x % j == 0 and y % j == 0 x % j == 0 x % j x j 0 y % j == 0 y % j y j 0 A = max(A, j) A max(A, j) max A j return A A x x y y x, y = map(int, input().split(" ")) x map(int, input().split(" ")) map int input().split(" ") ().split () input split " " y print(div(x,y)) print div(x,y) div x y x, y = map(int, input().split(" ")) map(int, input().split(" ")) x y = map(int, input().split(" ")) map(int, input().split(" ")) y def div(x, y): #x>y
    A = 1
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0 and y % i == 0:
            A = max(A, i)
        j = int(x/i)
        if x % j == 0 and y % j == 0:
            A = max(A, j)
    return A def div(x, y): #x>y
    A = 1
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0 and y % i == 0:
            A = max(A, i)
        j = int(x/i)
        if x % j == 0 and y % j == 0:
            A = max(A, j)
    return A div
import math
def div(x, y): #x>y
    A = 1
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0 and y % i == 0:
            A = max(A, i)
        j = int(x/i)
        if x % j == 0 and y % j == 0:
            A = max(A, j)
    return A
x, y = map(int, input().split(" "))
print(div(x,y))



