n, m = map(int, input().split()) for i in range(m, 1, -1): if n % i == 0: print(n // i) break else: print(-1)