// Arup Guha
// 10/12/2013
// Solution to UCF JV Practice Problem I: Primes on Interval.

import java.util.*;

public class i {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int a = stdin.nextInt();
		int b = stdin.nextInt();
		int k = stdin.nextInt();

		boolean[] sieve = new boolean[1000100];
		Arrays.fill(sieve, true);
		sieve[0] = false; sieve[1] = false;

		// Prime Sieve...
		for (int i=2; i<Math.sqrt(sieve.length)+1; i++)
			if (sieve[i])
				for (int j=2*i; j<sieve.length; j+=i)
					sieve[j] = false;

		// Count primes.
		int numPrimes = 0;
		for (int i=0; i<sieve.length; i++)
			if (sieve[i])
				numPrimes++;

		// Copy Primes
		int[] primes = new int[numPrimes];
		int j = 0;
		for (int i=0; i<sieve.length; i++)
			if (sieve[i])
				primes[j++] = i;

		// Find first index >= a.
		int low = 0;
		while (primes[low] < a) low++;

		// Endpoint so range has exactly k primes.
		int high = low+k-1;

		// No solution, since range has fewer than k primes.
		if (high > primes.length || primes[high] > b)
			System.out.println("-1");

		else {

			// This is the first range, starting at a with k primes.
			// Our answer can only go up from here.
			int curAns = primes[high] - a + 1;

			// We must check all ranges until here.
			while (primes[high] <= b) {

				// Slide over to the next set of primes.
				low++;
				high++;

				// Got to end.
				if (primes[high] > b) {

					// Test our previous starting point till b.
					int thisAns = b - primes[low-1] + 1;
					if (thisAns > curAns)
						curAns = thisAns;
				}

				// Here is our next range, from the next prime to right after our old first one.
				else {
					int thisAns = primes[high] - primes[low-1];
					if (thisAns > curAns)
						curAns = thisAns;
				}
			}
			System.out.println(curAns);
		}
	}
}