#t288. 因子问题

因子问题

Factors Problem

Problem Background

Special for beginners, ^_^

Problem Description

Given two positive integers NN and MM, find the smallest positive integer aa such that both aa and (M−a)(M - a) are factors of NN.

Input Format

Two integers NN and MM. NN does not exceed 1,000,0001{,}000{,}000.

Output Format

Output one integer aa as the result. If no positive integer satisfying the condition exists for a given case, output −1-1 in the corresponding line.

Sample Input

35 10

Sample Output

5

Constraints

1s, 1024KiB for each test case.