import collections
import math


def factorization(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def main():
    a = list(map(int, input().split()))
    c = sorted(collections.Counter(factorization(a[1])).items(), key=lambda x:x[1], reverse=True)
    ans = 1
    for s in c:
        if math.floor(s[1] / a[0]) >= 1:
            ans *= s[0] * math.floor(s[1] / a[0])
        else:
            break
    print(int(ans))


if __name__ == "__main__":
    main()
