Prime Protocol
In the kingdom of MAPS, the royal archives contain a sequence of scrolls numbered from X to Y. The Prime Minister (literally a minister obsessed with prime numbers) has devised a new Prime Security Protocol to ensure the archives remain safe from spies.
The protocol states that for every window of exactly M consecutive scrolls, there must be at least K prime-numbered scrolls to ensure numerical purity. If a spy tries to extract knowledge from the archives, they will always encounter a sufficient number of prime scrolls in any section, dismantling their evil plans.
As the kingdom's Chief Mathematician, you must determine the smallest possible M that satisfies this protocol. If there exists no valid M, report −1 to the Prime Minister.
Input
A single line containing three integers X, Y, K.
Output
A single line containing one integer M (if it exists) or −1.
Constraints
- 1≤X,Y,K,≤106
- X≤Y
Example 1
2 4 2
3
Example 2
2 4 3
-1
Example 3
6 13 1
4
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.