import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class G {

    public static void main(String[]args) throws IOException{
        int[] criba=criba(1000005);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input=br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int k = Integer.parseInt(input[2]);
        int maxI = (b-a+1);
        boolean flag = false;
        int minI= k, i = -1;
        while(minI<=maxI){
            int mid = (maxI+minI)/2;
            for (int x = a; x <= (b - mid + 1); x++){
                int primos = criba[x+mid-1]-criba[x-1];
                if (primos<k){
                    break;
                }
                else if (x==b-mid+1){
                    flag=true;
                }
            }
            if (flag){
                maxI=mid-1;
                i = mid;
                flag=false;
            }
            else{
                minI=mid + 1;
            }
        }

        System.out.println(i);

    }

    public static int[] criba(int tamano){
        int[] lista = new int[tamano];
        int[] listaAux = new int[tamano];
        listaAux[0]=1;
        listaAux[1]=1;
        int contador=0;
        for(int i=0; i<tamano;i++){
            if (listaAux[i]==0){
                for (int j=0; j*i<tamano;j++){
                    listaAux[j*i]=1;
                }
                contador++;
            }
            lista[i] = contador;
        }
        return lista;
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class C {

    static int n;
    static boolean[] primes;

    public void gen() {

        primes = new boolean[n + 5];
        Arrays.fill(primes, true);

        primes[0] = false;
        primes[1] = false;

        for (int i = 2; i * i <= n; i++)
            if (primes[i])
                for (int j = i * i; j <= n; j += i)
                    primes[j] = false;

    }

    private void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
        int k = nextInt();
        n = (int) 5000000;
        gen();
        int[] p = new int[b - a + 1];
        p[0] = primes[a] ? 1 : 0;
        int c = a + 1;
        for (int i = 1; i < b - a + 1; i++) {
            p[i] = p[i - 1] + (primes[c++] ? 1 : 0);
        }
        int lo = 1, hi = b - a + 1, mid = 0;
        boolean nothing = false;
        int iter = 40;
        while (lo <= hi && iter-- > 0) {
            mid = lo + (hi - lo) / 2;
            boolean ok = true;
            for (int i = 0; i < b - a + 1 && (i + mid - 1) < p.length; i++) {
                if (i - 1 < 0) {
                    if (p[i + mid - 1] < k) {
                        ok = false;
                        break;
                    }
                }
                else if (p[i + mid - 1] - p[i - 1] < k) {
                    ok = false;
                    break;
                }
            }
            nothing |= ok;
            if (ok) {
                hi = mid;
            } else {
                lo = mid + 1;
            }
        }
        pl(!nothing ? -1 : hi);
    }

    public static void main(String[] args) {
        new C().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}

import java.io.*;
import java.util.*;

public class Main implements Runnable {
  public static final int SZ = 1000050;
  public BufferedReader br;
  public int a, b, k, ans;
  public boolean[] prime;
  public int[] dp;

  public boolean func(int thre) {
    int cnt = Integer.MAX_VALUE;
    for (int i = a, j = a + thre - 1; j <= b; i++, j++)
      cnt = Math.min(cnt, dp[j] - dp[i-1]);
    return cnt >= k;
  }

  public void run() {
    int low, up, mid;
    try {
      br = new BufferedReader(new InputStreamReader(System.in));
      String[] ss = br.readLine().split(" ");
      a = Integer.parseInt(ss[0]);
      b = Integer.parseInt(ss[1]);
      k = Integer.parseInt(ss[2]);

      prime = new boolean[SZ];
      Arrays.fill(prime, true);
      prime[0] = prime[1] = false;
      for (int i = 2; i <= 1005; i++)
        if (prime[i])
          for (int j = i * i; j < SZ; j += i)
            prime[j] = false;

      dp = new int[SZ];
      dp[0] = 0;
      for (int i = 1; i < SZ; i++)
        if (prime[i])
          dp[i] = dp[i-1] + 1;
        else
          dp[i] = dp[i-1];

      ans = -1;
      low = 1;
      up = b - a + 1;
      while (low <= up) {
        mid = low + up >> 1;
        if (func(mid)) {
          ans = mid;
          up = mid - 1;
        }
        else
          low = mid + 1;
      }
      System.out.println(ans);
    }
    catch (Throwable rubbish) {
      System.err.println("Rubbish is thrown");
    }
  }

  public static void main(String[] args) {
    new Thread(new Main()).start();
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class POI {
    static int SIZE = 1100000;
    static ArrayList<Integer> primes = sieve(SIZE);
    static ArrayList<Integer> sieve(int N){
        boolean[] isPrime = new boolean[N + 1];
        ArrayList<Integer> res = new ArrayList<Integer>();
        res.add(0);
        for (int i = 2; i <= N; i++) {
            isPrime[i] = true;
        }
        int i=2;
        for (; i*i <= N; i++) {
            if (isPrime[i]) {
                res.add(i);
                for (int j = i; i*j <= N; j++) {
                    isPrime[i*j] = false;
                }
            }
        }
        for(;i<=N;i++){
            if(isPrime[i])
                res.add(i);
        }
        return res;
    }
    public static void main(String[] args) throws IOException {
        String[] line = new BufferedReader(new InputStreamReader(System.in)).readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int k = Integer.parseInt(line[2]);
        int i=0;
        while(primes.get(i) < a) i++;
        int j=i;
        while(primes.get(j) <= b) j++;
        if(j-i < k){
            System.out.println(-1);
            return;
        }
        //System.out.println(primes.get(j));
        //System.out.println(primes.get(i+k-1)-a+1);
        //System.out.println(b-primes.get(j-k)+1);
        int l = Math.max(primes.get(i+k-1)-a+1, b-primes.get(j-k)+1);
        for(;i+k < j;i++){
            //System.out.println(l);
            l = Math.max(l, primes.get(i+k)-primes.get(i));
        }
        //if(l==0) l = b-a+1;
        System.out.println(l);
        //binarySearch(a,b,k,1,b-a+1);
    }
    private static void binarySearch(int a, int b, int k, int i, int j) {
        while(i<=j){
            int mid = (i+j)>>1;
            if(satisfiable(mid,a,b,k)){
                j = mid-1;
            } else {
                i = mid+1;
            }
        }
    }
    private static boolean satisfiable(int l, int a, int b, int k) {

        return false;
    }
}

import java.util.* ;
import java.io.*;

public class Problems {

    private static ArrayList<Integer> pIndex ;

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        /*
        6 13 1
         */
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();

        pIndex = new ArrayList<>() ;
        int allP = countPrimes(a , b);

        if(allP < k){
            out.println(-1);
            out.close();
            return ;
        }

        int max = pIndex.get(k-1) + 1 - a ;
        int sIndex = 0  ;
        int start = pIndex.get(sIndex++) ;

        for(int i = k ; i < pIndex.size() ; i++){

                max =Math.max(pIndex.get(i) - start, max );
                start = pIndex.get(sIndex++) ;

        }
        max = Math.max(b +1 - pIndex.get(pIndex.size()-k), max) ;

        out.println(max) ;

        out.close();

    }

    public static int countPrimes(int a , int b) {
        int numOfPrimes = 0 ;
        for (int i = a; i <= b; ++i) {

            boolean s = true;

            for (int x = 2; x * x <= i; ++x) {
                if (i % x == 0) {
                    s = false;
                    break;
                }
            }
            if (s) {
                if(i == 1) continue ;
                pIndex.add(i);
                ++numOfPrimes;
            }
        }
        return numOfPrimes ;
    }

}

class InputReader {

    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.io.*;
import java.util.*;

public class Main
{
    static int [] prime  ;
    static void sieve(int N)
    {
        prime = new int [N + 1] ;
        Arrays.fill(prime , 1);
        prime[0] = prime[1] = 0 ;
        for(int i = 2 ;i <= N ; i++)
            if(prime[i] == 1)
                for(int j = i * 2 ; j <= N ; j += i)
                    prime[j] = 0 ;
        for(int i = 1 ; i <= N ; i ++)
            prime[i] += prime[i - 1] ;
    }
    public static void main(String[] args) throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine()) ;
        int a = Integer.parseInt(st.nextToken()) , b = Integer.parseInt(st.nextToken()) , k = Integer.parseInt(st.nextToken()) ;
        sieve(b);
        int start = 1 , end = b - a + 1  , min = -1;
        while(start <= end)
        {
            boolean can = true ;
            int mid = start + end >> 1 ;
            for(int x = a ; x <= b - mid + 1 ; x++)
                can &= (prime[x + mid - 1] - prime[x - 1] >= k);
            if(can)
            {
                min = mid;
                end = mid - 1 ;
            }
            else
                start = mid + 1 ;
        }
        System.out.println(min);
        out.flush();
    }
}

import java.io.*;
import java.math.*;
import java.util.*;
public class Solution
{
    static boolean is_prime[];
    static int[] prime_count;
    static int a;
    static int b;
    static int k;
    public static boolean is_possible(int l){
        for(int i=a;i<=(b-l+1);i++)
     {
         if((prime_count[i+l-1]-prime_count[i-1])<k)
             return false;
     }
     return true;
    }

    public static void sieve()
    {
        for(int i=2;i<=1000000;i++)
        {
            if(is_prime[i]==true)
            {
                for(int j=2*i;j<=1000000;j+=i)
                {
                    is_prime[j]=false;
                }
            }
        }
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        Scan sn=new Scan();
        Print p=new Print();
        is_prime=new boolean[1000000+1];
        Arrays.fill(is_prime,true);
        is_prime[1]=false;
        sieve();
        a=sn.scanInt();
        b=sn.scanInt();
        k=sn.scanInt();
        prime_count=new int[1000000+1];
        for(int i=1;i<=1000000;i++)
        {
            if(is_prime[i]==true)
                prime_count[i]=prime_count[i-1]+1;
            else
                prime_count[i]=prime_count[i-1];
        }
       int lo=1;
        int hi=(b-a+1);
        while(lo<hi)
        {
            int mid=lo+((hi-lo)/2);
            if(is_possible(mid))
                hi=mid;
            else
                lo=mid+1;
        }
        if(is_possible(lo))
            p.printLine(Integer.toString(lo));
        else
            p.printLine("-1");
        p.close();
    }
}
class Scan
{
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;
    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
            throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
                return -1;
        }
        return buf[index++];
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
            n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
            n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
            n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    private boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
        return false;
    }
}

class Print
{
    private final BufferedWriter bw;
    public Print()
    {
        bw=new BufferedWriter(new OutputStreamWriter(System.out));
    }
    public void print(String str)throws IOException
    {
        bw.append(str);
    }
    public void printLine(String str)throws IOException
    {
        print(str);
        bw.append("\n");
    }
    public void close()throws IOException
    {
        bw.close();
    }}

//package sheet_C;
import java.io.*;
import java.util.*;
public class PrimesOnInterval {

	static int a;

	static ArrayList<Integer> primes;
	static boolean[] isComposite;

	public static void main(String[]args)throws Throwable{
		PrintWriter pw=new PrintWriter(System.out,true);
		MyScanner sc=new MyScanner();

		a=sc.nextInt();
		int b=sc.nextInt();
		int k=sc.nextInt();
		sieve(b);

		int ans=-1;
		int n=primes.size();

		if(n<k){
			pw.println(ans);
			return;
		}

		for(int i=0;i<n-k;i++){
			ans=Math.max(ans, primes.get(i+k)-primes.get(i));
		}

		if(isComposite[a])
			ans=Math.max(ans, primes.get(k-1)-a+1);

		if(isComposite[b])
			ans=Math.max(ans, b-primes.get(n-k)+1);

		if(ans==-1)
			ans=b-a+1;

		pw.println(ans);

		pw.flush();
		pw.close();
	}

	static void sieve(int N)
	{
		isComposite = new boolean[N+1];
		isComposite[0] = isComposite[1] = true;
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i)
			if (isComposite[i] == false)
			{
				if(i>=a)
					primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)
						isComposite[j] = true;
			}
	}

	static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;

	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }

	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }

	      int nextInt() {
	          return Integer.parseInt(next());
	      }

	      long nextLong() {
	          return Long.parseLong(next());
	      }

	      double nextDouble() {
	          return Double.parseDouble(next());
	      }

	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }
}

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class TC
{
    static ArrayList<Integer> primes;
    static boolean isPrime[];

    static void sieve()
    {
        int n = 10001;
        isPrime = new boolean[ n ];
        Arrays.fill( isPrime, true );
        primes = new ArrayList();
        isPrime[ 1 ] = false;

        for( int i=2; i<n; i++ )
        {
            if( isPrime[ i ])
            {
                primes.add( i );

                int mul = 2;

                while( mul*i < n )
                {
                    isPrime[ mul*i ]  = false;
                    mul++;
                }
            }
        }

    }

    static boolean checkPrime( int n )
    {
        for( int i=0; i<primes.size(); i++ )
        {
            int p = primes.get( i );
            if( n%p == 0 )
                return false;
        }

        return true;
    }

    static int solve( int a, int b, int k )
    {
        if( k > ( b-a+1 ))
            return -1;

        boolean isP[] = new boolean[ b-a+2 ];
        Arrays.fill( isP, false);

        ArrayList<Integer> rangeP = new ArrayList();

        for( int i=a; i<=b; i++ )
        {
            if( i <=10000 )
            {
                if( isPrime[ i ])
                {
                    rangeP.add( i );
                    isP[ i-a ] = true;
                }
            }

            else
            {
                if( checkPrime( i ))
                {
                    rangeP.add( i );
                    isP[ i-a ] = true;
                }
            }

        }

        if( rangeP.size() < k )
            return -1;

        int index = k-1;
        int end = rangeP.get(k-1);
        int MAX = -1;

        for( int i=0; i<=b-a; i++ )
        {
            if( !isP[ i ])
            {
                int window = ( end -a )  - ( i ) + 1;
                MAX = Math.max( MAX, window );
            }

            else
            {
                index++;

                if(index  < rangeP.size() )
                    end = rangeP.get( index );

                else
                {
                    MAX = Math.max( MAX, b - ( a+i ) + 1 );
                    break;
                }
            }

        }

        return MAX;

    }

    public static void main( String[] args ) throws IOException
    {
        Scanner s = new Scanner( System.in );

        int a = s.nextInt();
        int b = s.nextInt();
        int k = s.nextInt();

        sieve();
        int res = solve( a, b, k );
        System.out.println( res );
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Primes {
	public static void main(String[] args) throws IOException{
		BufferedReader br;
	    br = new BufferedReader(new InputStreamReader(System.in));
	    String lecture = br.readLine();
	    String[] split = lecture.split(" ");
	    int a = Integer.parseInt(split[0]);
	    int b = Integer.parseInt(split[1]);
	    int k = Integer.parseInt(split[2]);
	    int i;

	    boolean[] criba = new boolean[b+2];
	    Arrays.fill(criba,true);
	    criba[0] = criba[1] = false;
	    int root = (int)Math.sqrt(b+1)+1;
	    for(i=2; i<root; i++){
	    	if(criba[i]){
	    		for(int j=i*i;j<=b+1;j+=i){
	    			criba[j] = false;
	    		}
	    	}
	    }

	    int[] cont = new int[b+2];

	    for (i=b; i>=a; i--){
	    	if (criba[i])
	    		cont[i]++;
	    	cont[i]+=cont[i+1];
	    }
	    //for (i=a;i<=b;i++)
	    	//System.out.println(i+" "+criba[i]+" "+cont[i]);
	    int l = 1;
	    boolean one = false;

	    for (i=a; i<=b-l+1; i++){
	    	while (cont[i]-cont[i+l]<k){
	    		l++;
	    		if (i+l>b+1){
	    			if (one)
	    		    	System.out.println(l);
	    		    else
	    		    	System.out.println(-1);
	    			System.exit(0);
	    		}
	    	}
	    	one = true;
	    }

	    System.out.println(l);
	}
}

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class ProblemC {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int a = in.nextInt();
		int b = in.nextInt();
		int k = in.nextInt();
		boolean[] isp = new boolean[1000010];
		Arrays.fill(isp, true);
		isp[1] = false;
		for (int i = 2 ; i < 1000010 ; i++) {
			if (isp[i]) {
				for (int ii = i * 2 ; ii < 1000010 ; ii += i) {
					isp[ii] = false;
				}
			}
		}

		int[] imos = new int[b-a+2];
		for (int i = a ; i <= b; i++) {
			int j = i-a;
			imos[j+1] = imos[j] + (isp[i] ? 1 : 0);
		}
		if (imos[imos.length-1] < k) {
			out.println(-1);
			out.flush();
			return;
		}

		int min = 0;
		int max = (b-a)+1;
		while (max - min > 1) {
			int med = (max + min) / 2;
			if (ispossible(med, imos, k)) {
				max = med;
			} else {
				min = med;
			}
		}
		out.println(max);
		out.flush();
	}

	private static boolean ispossible(int med, int[] imos, int k) {
		int l = imos.length-1;
		for (int i = 0 ; i <= (l-med) ; i++) {
			if (imos[i+med]-imos[i] < k) {
				return false;
			}
		}
		return true;
	}

	public static void debug(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}
}

import java.util.ArrayList;
import java.util.BitSet;
import java.util.Scanner;

public class CF_237C {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt(), b = scan.nextInt(), k = scan.nextInt();

		ArrayList<Integer> primes = new ArrayList<>();
		BitSet sieve = new BitSet(b+1);
		sieve.set(0);
		sieve.set(1);

		for(int i=2;i*(long)i<=b;i++) {
			if(sieve.get(i))
				continue;
			for(long j=i*i;j<=b;j+=i)
				sieve.set((int)j);
		}
		for(int i=a;i<=b;i++) {
			if(sieve.get(i)) continue;
			primes.add(i);
		}
		// System.err.println(primes);
		int pPtr = 0;
		int maxLSeen = 0;
		int ans = -1;
		for(int i=a;i<=b;i++) {
			while(pPtr < primes.size() && primes.get(pPtr) < i)
				pPtr++;
			if(primes.size() - pPtr < k) {
				break;
			}
			maxLSeen = Math.max(maxLSeen, primes.get(pPtr+k-1)-i+1);
			int curL = b-i+1;
			if(maxLSeen <= curL && (curL < ans || ans == -1)) {
				ans = curL;
			}

		}
		System.out.println(ans);
	}
}

import java.util.*;
public class sol {

    public static void main(String[] args) {
        Scanner me = new Scanner(System.in);

        final int cs = 1 << 20;

        int u[] = new int[cs];
        int sum[] = new int[cs];
        for (int i = 2; i < cs; i++)
            if (u[i] == 0)
                for (int j = i + i; j < cs; j += i)
                    u[j] = 1;

        for (int i = 2; i < cs; i++)
            sum[i] = sum[i - 1] + (u[i] ^ 1);

        //for(int i = 1 ; i < 10 ; i ++)
        //  out.println(sum[i]);

        int a, b, k;

        a = me.nextInt();
        b = me.nextInt();
        k = me.nextInt();

        int low = 1, high = b - a + 1, mid, best_ok = 12345678;

        for (int tt = 1; tt < 25; tt++) {
            mid = (low + high) >> 1;

            int ok = 1;

            for (int i = a; i <= b - mid + 1; i++)
                if (sum[i + mid - 1] - sum[i - 1] < k) {
                    ok = 0;
                    break;
                }

            if (ok == 1) {
                if (mid < best_ok)
                    best_ok = mid;
                high = mid;
            } else low = mid + 1;
        }

        if (best_ok == 12345678)
            best_ok = -1;
        System.out.println(best_ok);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class PrimesOnInterval {

	static StreamTokenizer st;
	static int nextInt() {
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (int) st.nval;
	}

	static int BOUND = 1000000;
	static boolean[] isComposite = new boolean[BOUND + 1];
	static int[] primesCount = new int[BOUND + 1];
	static int nbPrimes = 1;

	static void seive() {
		isComposite[0] = isComposite[1] = true;
		primesCount[1] = 1;
		for(int i = 2; i <= BOUND; i++) {
			if(!isComposite[i]) {
				nbPrimes++;
				for(int j = i + i; j <= BOUND; j += i)
					isComposite[j] = true;
			}
			primesCount[i] = nbPrimes;
		}
	}

	static int a, b ,k;
	public static void main(String[] args) {
		st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

		seive();

		a = nextInt();
		b = nextInt();
		k = nextInt();

		System.out.println(binarySearch(1, b - a + 1));
	}

	static int binarySearch(int low, int high) {
		if(low >= high) {
			return goLeft(low) ? low : -1;
		}

		int mid = (high + low) / 2;

		if(goLeft(mid)) {
			int l =  binarySearch(low, mid);
			return l == -1 ? mid : l;
		}
		return binarySearch(mid + 1, high);
	}

	static boolean goLeft(int l) {
		for(int x = a; x <= (b - l + 1); x++) {
			int primes = primesCount[x + l - 1] - primesCount[x];
			if(!isComposite[x])
				primes++;
			if(primes < k)
				return false;
		}
		return true;
	}
}

//237C

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class PrimesOnInterval {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		boolean[] nonprime = new boolean[1000001];
		nonprime[0]=nonprime[1] = true;
		for (int i = 2; i < nonprime.length; i++) {
			if (!nonprime[i]) {
				for (int j = i<<1; j < nonprime.length; j += i) {
					nonprime[j] = true;
				}
			}
		}
		int[] cum = new int[1000001]; // Plas

		for (int i = 1; i < cum.length; i++) {
			cum[i] = cum[i-1] + (nonprime[i] ? 0 : 1);
		}

		StringTokenizer st = new StringTokenizer(br.readLine());

		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());

		// TODO Binsearch l en [1, b-a+1]
		int i = 1;
		int j = b-a+2;
		for (int m = (i+j)/2; i < j; m = (i+j)/2) {
			boolean success = true;
			for (int x = a; x <= b-m+1; x++) {
				if (cum[x+m-1] - cum[x-1] < k){
					success = false;
					break;
				}
			}
			if (success) {
				j = m;
			}
			else {
				i = m+1;
			}
		}
		System.out.println((i > b-a+1) ? -1 : i);
	}
}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author mdonaj
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();

        boolean[] primes = new boolean[b+10];
        Arrays.fill(primes, true);
        primes[0] = false;
        primes[1] = false;

        for(int i = 2; i <= b; ++i) {
            if(!primes[i])
                continue;
            int c = i;

            for(int j = i + c; j <= b; j += c)
                primes[j] = false;
        }

        int[] cnt = new int[b+1];
        int curr = 0;
        for(int i = 0; i <= b; ++i) {
            if(primes[i])
                curr++;
            cnt[i] = curr;
        }

        int l = -1;
        for(int i = a; i <= b; ++i) {

            int next = k+cnt[i];
            if(primes[i])
                next--;

            int idx = Arrays.binarySearch(cnt, next);
            if(idx < 0 && l > 0) {
                l = Math.max(l, b-i+2);
                break;
            }

            if(idx < 0 && l < 0)
                break;

            while(idx != 0 && cnt[idx] == cnt[idx -1]) idx--;
            l = Math.max(l, idx - i + 1);
        }

        out.println(l);

	}
}

import java.io.*;
import java.util.*;

public class p1 {

	static int maxn = 1000001;
	static boolean[] p;

	static void pre() {
		p[0] = p[1] = true;
		for(int i = 2; i < maxn; i++) {
			if(p[i]) continue;
			for(int j = i + i; j < maxn; j += i)
				p[j] = true;
		}
	}

	public static void main(String[] args) throws Exception{
		int t = 1;
		p = new boolean[maxn];
		pre();
		int[] cnt = new int[maxn];
		for(int i = 1; i < maxn; i++)
			cnt[i] = cnt[i - 1] + (p[i] ? 0 : 1);

		while(t--> 0) {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			PrintWriter out = new PrintWriter(System.out);
			int tc = 1;
			for(int iter = 1; iter <= tc; iter++) {
				String[] input = br.readLine().split(" ");
				int a = Integer.parseInt(input[0]);
				int b = Integer.parseInt(input[1]);
				int k = Integer.parseInt(input[2]);
				int l = 1;
				int r = b - a + 1;
				int ans = -1;
				while(r - l >= 0) {
					int mid = (l + r) >> 1;
					int count = b - (a + mid - 1) + 1;
					for(int i = a + mid - 1; i <= b; i++) {
						if(cnt[i] - cnt[i - mid] >= k)
							count--;
					}
					if(count == 0) {
						r = mid - 1;
						ans = mid;
					}
					else l = mid + 1;
				}
				out.println(ans);
			}

			out.close();
		}
	}

	static void debug(Object... o) {
	    System.out.println(Arrays.deepToString(o));
	}

}

import java.util.Scanner;

public class b {
  public static final int maxn = 1001000;
  public static boolean[] np = new boolean[maxn];
  public static int[] sum = new int[maxn];

  public static int get (int l, int r) {
    return sum[r] - (l > 0 ? sum[l - 1] : 0);
  }

  public static boolean check (int x, int a, int b, int k) {
    for (int i = a; i <= b - x + 1; i++)
      if (get (i, i + x - 1) < k)
        return false;
    return true;
  }

  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    np[0] = np[1] = true;
    for (int i = 2; i < maxn; i++)
      if ((long)i*i < maxn)
        for (int j = i * i; j < maxn; j += i)
          np[j] = true;

    for (int i = 1; i < maxn; i++)
      sum[i] = sum[i - 1] + (np[i] ? 0 : 1);

    int a = in.nextInt(), b = in.nextInt(), k = in.nextInt();
    int L = 1, R = b - a + 1, ans = -1, M;
    while (L <= R) {
      M = (L + R)/2;
      if (check (M, a, b, k)) {
        ans = M; R = M - 1;
      } else {
        L = M + 1;
      }
    }
    System.out.println(ans);
  }
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A{

	public static void main(String args[]) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		boolean[] p = sieve((int) 1e6);
		int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
		int l = -1;
		// bs
		int lo = k, hi = b - a + 1;
		while (lo <= hi) {
			int mid = (lo + hi) / 2;
			int sum = 0;
			for (int i = a; i - a < mid; i++) {
				if (p[i])
					sum++;
			}
			boolean flag = sum >= k;
			int j = a + 1;
			while (flag && j + mid - 1 <= b) {
				if (p[j + mid - 1])
					sum++;
				if (p[j - 1])
					sum--;
				if(sum < k)
					flag = false;
				j++;
			}
			if (flag) {
				l = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		out.println(l);
		out.flush();
		out.close();
	}
	public static boolean[] sieve(int n) {
		boolean[] prime = new boolean[n + 1];
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		int m = (int) Math.sqrt(n);
		for (int i = 2; i <= m; i++)
			if (prime[i])
				for (int k = i * i; k <= n; k += i)
					prime[k] = false;
		return prime;
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}

import java.util.*;
import java.lang.*;
import java.math.*;
import java.awt.image.ConvolveOp;
import java.io.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;
public class Codeforces{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long MOD = (long)(1e9+7);
	static FastReader sc = new FastReader();
	static int pInf = Integer.MAX_VALUE;
	static int nInf = Integer.MIN_VALUE;
	public static void main(String[] args){
		int test = 1;
		//test = sc.nextInt();
		while(test-->0){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int k = sc.nextInt();
			int[] primes = findPrimes(b);
			ArrayList<Integer> A = new ArrayList<>();
			for(int i = 0; i < primes.length; i++) {
				if(primes[i]<a) {
					continue;
				}
				A.add(primes[i]);
			}
			if(k>A.size()) {
				out.print(-1);
				continue;
			}
			int ans = nInf;
			for(int i = 0; i+k < A.size(); i++) {
				int f = A.get(i+k)-A.get(i);
				ans = Math.max(ans, f);
			}
			ans = Math.max(ans, A.get(k-1)-a+1);
			ans = Math.max(ans, b-A.get(A.size()-k)+1);
			out.println(ans);
			//out.println(A);
  		}
		out.close();
	}
	public static long mul(long a, long b){
	    return ((a%MOD)*(b%MOD))%MOD;
	}
	public static long add(long a, long b){
	    return ((a%MOD)+(b%MOD))%MOD;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Integer.lowestOneBit(i)   Equals k where k is the position of the first one in the binary
//Integer.highestOneBit(i)  Equals k where k is the position of the last one in the binary
//Integer.bitCount(i)       returns the number of one-bits
//Collections.sort(A,(p1,p2)->(int)(p2.x-p1.x)) To sort ArrayList in descending order wrt values of x.
//            Arrays.parallelSort(a,new Comparator<TPair>() {
//      		public int compare(TPair a,TPair b) {
//        			if(a.y==b.y) return a.x-b.x;
//        			return b.y-a.y;
//        		}
//        	});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PrimeFactors
    public static ArrayList<Long> primeFactors(long n) {
        ArrayList<Long> arr = new ArrayList<>();
        if (n % 2 == 0)
            arr.add((long) 2);
        while (n % 2 == 0)
            n /= 2;
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            int flag = 0;
            while (n % i == 0) {
                n /= i;
                flag = 1;
            }
            if (flag == 1)
                arr.add(i);
        }
        if (n > 2)
            arr.add(n);
        return arr;
    }
//Pair Class
	static class Pair implements Comparable<Pair>{
		int x;
		int y;
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(Pair o) {
			if(this.x==o.x){
			    return (this.y-o.y);
			}
			return (this.x-o.x);
		}
	}
	static class TPair{
		long x;
		long y;
		public TPair(long x, long y) {
			this.x = x;
			this.y = y;
		}
	}
//Merge Sort
	static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long [n1];
        long R[] = new long [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
//Brian Kernighan’s Algorithm
    static long countSetBits(long n){
        if(n==0) return 0;
        return 1+countSetBits(n&(n-1));
    }
//Factorial
    static long factorial(long n){
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 6;
        return n*factorial(n-1);
    }
//Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
//Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
//AKS Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i<=Math.sqrt(n);i+=6)
            if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
//Reverse an array
    static <T> void reverse(T arr[],int l,int r){
    	Collections.reverse(Arrays.asList(arr).subList(l, r));
    }
//Sieve of eratosthenes
    static int[] findPrimes(int n){
        boolean isPrime[]=new boolean[n+1];
        ArrayList<Integer> a=new ArrayList<>();
        int result[];
        Arrays.fill(isPrime,true);
        isPrime[0]=false;
        isPrime[1]=false;
        for(int i=2;i*i<=n;++i){
            if(isPrime[i]==true){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        for(int i=0;i<=n;i++) if(isPrime[i]==true) a.add(i);
        result=new int[a.size()];
        for(int i=0;i<a.size();i++) result[i]=a.get(i);
        return result;

    }
//Segmented Sieve
    static boolean[] segmentedSieve(long l, long r){
    	boolean[] segSieve = new boolean[(int)(r-l+1)];
    	Arrays.fill(segSieve, true);
    	int[] prePrimes = findPrimes((int)Math.sqrt(r));
    	for(int p:prePrimes) {
    		long low = (l/p)*p;
    		if(low < l) {
    			low += p;
    		}
    		if(low == p) {
    			low += p;
    		}
    		for(long j = low; j<= r; j += p) {
    			segSieve[(int) (j-l)] = false;
    		}
    	}
    	if(l==1) {
    		segSieve[0] = false;
    	}
    	return segSieve;
    }
//Euler Totent function
    static long countCoprimes(long n){
        ArrayList<Long> prime_factors=new ArrayList<>();
        long x=n,flag=0;
        while(x%2==0){
            if(flag==0) prime_factors.add(2L);
            flag=1;
            x/=2;
        }
        for(long i=3;i*i<=x;i+=2){
            flag=0;
            while(x%i==0){
                if(flag==0) prime_factors.add(i);
                flag=1;
                x/=i;
            }
        }
        if(x>2) prime_factors.add(x);
        double ans=(double)n;
        for(Long p:prime_factors){
            ans*=(1.0-(Double)1.0/p);
        }
        return (long)ans;
    }
	static long modulo = (long)1e9+7;
	public static long modinv(long x){
	    return modpow(x, modulo-2);
	}
	public static long modpow(long a, long b){
	    if(b==0){
	        return 1;
	    }
	    long x = modpow(a, b/2);
	    x = (x*x)%modulo;
	    if(b%2==1){
	        return (x*a)%modulo;
	    }
	    return x;
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class PrimesOnInterval {

	static boolean primes[] = new boolean[(int) 1e6 + 1];

	static void sieve() {
		primes[1] = true;
		primes[0] = true;
		for (int i = 2; i < primes.length; i++) {
			if (!primes[i])
				for (long j = 1l * i * i; j < primes.length; j += i)
					primes[(int) j] = true;
		}
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		sieve();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[b - a + 2];
		for (int i = 1; i <= b - a + 1; i++)
			p[i] = p[i - 1] + (!primes[i + a - 1] ? 1 : 0);
		int max = -1;
		int p1 = 0;
		int p2 = 1;
		while (p2 < p.length) {
			if (p[p2] - p[p1] < k)
				p2++;
			else
				p1++;
			max = Math.max(p2 - p1, max);
		}
		System.out.println(p[p.length - 1] - p[0] < k ? -1 : max);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public boolean nextEmpty() throws IOException {
			String s = nextLine();
			st = new StringTokenizer(s);
			return s.isEmpty();
		}
	}
}

//package round147;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int[] primes = sieveEratosthenes(1000000);
		boolean[] isp = new boolean[1000001];
		for(int p : primes){
			isp[p] = true;
		}
		int a = ni(), b = ni(), K = ni();
		int low = 0;
		int high = b-a+3;
		while(high - low > 1){
			int l = (high + low) / 2;
			int ct = 0;
			boolean ok = true;
			for(int i = a;i <= b;i++){
				if(isp[i])ct++;
				if(i-(l-1) >= a){
//					tr(i-l+1, i, ct);
					if(ct < K){
						ok = false;
						break;
					}
					if(i-(l-1) >= 1 && isp[i-(l-1)])ct--;
				}
			}
			if(ok){
				high = l;
			}else{
				low = l;
			}
		}
		if(high > b-a+1){
			out.println(-1);
		}else{
			out.println(high);
		}
	}

	public static int[] sieveEratosthenes(int n) {
		if(n <= 32){
			int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
			for(int i = 0;i < primes.length;i++){
				if(n < primes[i]){
					return Arrays.copyOf(primes, i);
				}
			}
			return primes;
		}

		int u = n + 32;
		double lu = Math.log(u);
		int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
		ret[0] = 2;
		int pos = 1;

		int[] isp = new int[(n + 1) / 32 / 2 + 1];
		int sup = (n + 1) / 32 / 2 + 1;

		int[] tprimes = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
		for(int tp : tprimes){
			ret[pos++] = tp;
			int[] ptn = new int[tp];
			for(int i = (tp - 3) / 2;i < tp << 5;i += tp)
				ptn[i >> 5] |= 1 << (i & 31);
			for(int i = 0;i < tp;i++){
				for(int j = i;j < sup;j += tp)
					isp[j] |= ptn[i];
			}
		}

		// 3,5,7
		// 2x+3=n
		int[] magic = { 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4,
				13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14 };
		int h = n / 2;
		for(int i = 0;i < sup;i++){
			for(int j = ~isp[i];j != 0;j &= j - 1){
				int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
				int p = 2 * pp + 3;
				if(p > n)
					break;
				ret[pos++] = p;
				for(int q = pp;q <= h;q += p)
					isp[q >> 5] |= 1 << (q & 31);
			}
		}

		return Arrays.copyOf(ret, pos);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new C().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.util.ArrayList;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        ArrayList<Integer> ar = sieve2(5000000);

        int primes[] = new int[5000000];
        for (int i = 0; i < ar.size(); i++) {
            primes[ar.get(i)] = 1;
        }
        int cum[] = new int[5000000];
        for (int i = 1; i < cum.length; i++) {
            cum[i] = cum[i-1] + primes[i];
        }

        int a = s.nextInt();
        int b = s.nextInt();
        int k = s.nextInt();

        int low = 1;
        int high = b - a + 1;
        int ans = -1;

        for (;low <= high;) {

            int l = (low + high) / 2;

            int ok = 1;
            for (int x = a; x <= b - l + 1 ; x++) {

                int sum = cum[x+l-1];
                if(x-1 >= 0) sum -= cum[x-1];
                if(sum < k){
                    ok = 0;
                    break;
                }

            }
            if(ok == 1){
                ans = l;
                high = l - 1;
//              System.out.println(l);
            }
            else low = l + 1;
        }
        System.out.println(ans);
    }

    public static ArrayList<Integer> sieve2(int n){// O( n )   MAX n = 10 000 000
        int lp[] = new int [n+1];//najmal prost delitel na i
        ArrayList<Integer> primes = new ArrayList<Integer>();
        for (int i = 2; i <= n ; i++) {
            if(lp[i]==0){
                lp[i]=i;
                primes.add(i);
            }
            for (int j = 0; j < primes.size() && primes.get(j) <= lp[i] && i*primes.get(j)<=n; j++) {
                lp[i*primes.get(j)]=primes.get(j);
            }
        }
        return primes;
    }
}

import java.io.*;
import java.util.*;

public class Main
{
	BufferedReader in;
	PrintStream out;
	StringTokenizer tok;
	public Main() throws NumberFormatException, IOException
	{
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new FileReader("in.txt"));
		out = System.out;
		run();
        }

	void run() throws NumberFormatException, IOException
	{
          Criba(1000001);
          //out.println(count);
          int a = nextInt();
          int b = nextInt();
          int k = nextInt();
          int resp = -1;
          //int[] cantP = new int[1000001];
          int p1 = a;
          int p2 = a;
          mask[0] = true;
          mask[1] = true;
          int cantp = 0;
          while(p1 <= b)
          {
              if(!mask[p1])
              {
                  cantp++;
                  if((cantp) == k)
                  {
                    resp = Math.max(resp, p1 - p2 + 1);
                    if(mask[p2])while(mask[p2])p2++;
                    p2++;
                    cantp--;
                  }
              }
              p1++;
          }
          cantp = 0;
          for(int i = b; i >= a; i--)
          {

              if(!mask[i])cantp++;
              if(cantp == k)
              {

                  resp = Math.max(resp, b - i + 1);
                          break;
               }
          }
          out.println(resp);
	}
 int[] Primos;
 int count = 0;
 boolean[] mask;

 void Criba(int n)
    {
	mask = new boolean[n+1];
	int raiz = (int)Math.sqrt(n);
Primos = new int[n/2+1];
	for (int i= 2; i <= 3; i++)
	for (int j = i*i; j <= n; j+=i)
		mask[j] = true;
	for(int i = 6; i<=raiz; i+=6)
      {
		i--;
		if(!mask[i])
		for (int j = i*i; j <= n; j	+= i)
			mask[j] = true;
		i += 2;
		if(!mask[i])
			for (int j = i*i; j <= n; j	+= i)
				mask[j] = true;
		i--;
      }
	Primos[0] = 2; Primos[1] = 3; count = 2;
	for(int i = 6; i <= n; i+=6)
	{
		if(!mask[i-1])Primos[count++] = i-1;
		if(!mask[i+1])Primos[count++] = i+1;
	}
    }

	public static void main(String[] args) throws NumberFormatException, IOException
	{
		new Main();
	}
        String nextToken() throws IOException
	{
		String line = "";
		while(tok == null || !tok.hasMoreTokens()) {
			if((line = in.readLine()) != null)
				tok = new StringTokenizer(line);
			else
				return null;
		}
		return tok.nextToken();
	}
	int nextInt() throws NumberFormatException, IOException
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws NumberFormatException, IOException
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws NumberFormatException, IOException
	{
		return Double.parseDouble(nextToken());
	}

}

import java.util.*;
import java.io.*;
import java.lang.*;
public class C237 {
	private static long mod = 1000000007;

	public static void main(String[] args) {
		InputReader in=new InputReader(System.in);
		PrintWriter pw=new PrintWriter(System.out);

		int a=in.nextInt();
		int  b=in.nextInt();
		int k=in.nextInt();

		boolean p[]=new boolean[1000006];
		sieve(p, 1000006);
		int[] dp=new int[1000006];
		dp[0]=0;
		dp[1]=0;
		for(int i=2;i<1000005;i++) {
			if(p[i])
				dp[i]=dp[i-1]+1;
			else
				dp[i]=dp[i-1];

		}
		int ans=-1;
		int start=1;
		int end=b-a+1;
		while(start<=end) {
			int mid=(end+start)/2;
			boolean flag=true;
			for(int i=a;i<=b-mid+1;i++) {
				int cnt=(dp[i+mid-1]-dp[i-1]);
				if(cnt<k) {
					flag=false;
					break;
				}
			}
				if(flag) {
					ans=mid;
					end=mid-1;
				}
				else
					start=mid+1;

		//	pw.println(ans);

		}
		pw.println(ans);

		pw.flush();
		pw.close();
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		public long[] nextLongArray(int n) {
			long a[] = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static ArrayList<Integer> primeFactorization(int n)
	{
		ArrayList<Integer> a =new ArrayList<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}
	}
}

import java.io.*;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * Created with IntelliJ IDEA.
 * User: DOAN Minh Quy
 * Date: 8/1/13
 * Time: 10:08 AM
 */
public class Task237C {
    public static void main(String[] args) {
        new Task237C().run();
    }

    void run() {
        Task237CReader reader = new Task237CReader(System.in);
        Task237CWriter writer = new Task237CWriter(System.out);
        int a = reader.nextInt();
        int b = reader.nextInt();
        int k = reader.nextInt();
        int[] prime = new int[b+1];
        Arrays.fill(prime,1);
        prime[0] = prime[1] = 0;
        for(int i = 4 ; i <= b ; i += 2 ){
            prime[i] = 0;
        }
        for(int i = 3 ; i <= b ; i += 2 ){
            if ( prime[i] == 1 ){
                if ( Math.sqrt(b) + 1 < i ) continue;
                for(int j = i * i ; j <= b ; j += i){
                    try{
                        prime[j] = 0;
                    }catch (Exception e){
                        writer.println(j);
                    }
                }
            }
        }
//        for(int i = 1 ; i <= b ; ++i){
//            writer.print(prime[i]+" ");
//        }
//        writer.println();
        for(int i = 1 ; i <= b ; ++i){
            prime[i] += prime[i-1];
        }
        int lo = 0, hi = b - a + 2;
        while(hi>lo){
            int mi = (lo + hi) >> 1;
            boolean got = true;
            for(int i = a - 1 ; got && i + mi <= b ; ++i){
                if ( prime[i+mi] - prime[i] < k ){
                    got = false;
                }
            }
            if ( got ){
                hi = mi;
            }else{
                lo = mi + 1;
            }
        }
        writer.println((lo>b-a+1)?-1:lo);
        writer.close();
    }
}

class Task237CReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public Task237CReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

}

class Task237CWriter {
    private final PrintWriter writer;

    public Task237CWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void println(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class TaskY {
    boolean[] isPrime;
    int[] primesSuff;
    int a;
    int b;
    int k;

    public static void main(String[] args) throws IOException {
        new TaskY().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        a = Integer.parseInt(tokenizer.nextToken());
        b = Integer.parseInt(tokenizer.nextToken());
        k = Integer.parseInt(tokenizer.nextToken());
        isPrime = new boolean[b + 1];
        makeSieve();
        primesSuff = new int[b + 1];
        for (int i = 0; i < primesSuff.length; i++) {
            if (isPrime[i]) primesSuff[i]++;
            if (i != 0) primesSuff[i] += primesSuff[i - 1];
        }

        int currDistance = 0;
        int maxDistance = 0;
        for (int i = a; i <= b; i++) {
            currDistance++;
            maxDistance = Math.max(currDistance, maxDistance);
        }

        out.println(binarySearch());
        out.close();
    }

    private int binarySearch() {
        int from = 1;
        int to = b - a + 1;
        int res = -1;
        while (from <= to) {
            int mid = (from + to) / 2;
            if (possibleL(mid)) {
                to = mid - 1;
                res = mid;
            } else {
                from = mid + 1;
            }
        }

        return res;
    }

    private boolean possibleL(int l) {
        for (int i = a; i <= b - l + 1; i++) {
            int left = i;
            int right = i + l -1;
            int in = primesSuff[right] - primesSuff[left - 1];
            if (in < k) return false;
        }

        return true;
    }

    private void makeSieve() {
        Arrays.fill(isPrime, true);
        for (int i = 0; i <= 1; i++) isPrime[i] = false;
        for (int i = 2; i < isPrime.length; i++) {
            if (isPrime[i]) {
                for (int j = i * 2; j < isPrime.length; j += i) {
                    isPrime[j] = false;
                }
            }
        }
    }
}

import java.util.Scanner;

public class C {
    static int[] primes;
    static int a, b, k;

    static void seive(int n) {
        boolean[] v = new boolean[n + 1];
        for (int i = 2; i * i <= n; i += (1 + (i & 1)))
            for (int j = i + i; j <= n; j += i)
                v[j] = true;

        primes = new int[n + 1];
        for (int i = 2; i <= n; i++)
            if (!v[i])
                primes[i] = 1;

        for (int i = 1; i <= n; i++)
            primes[i] += primes[i - 1];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        a = in.nextInt();
        b = in.nextInt();
        k = in.nextInt();
        seive(b + 1);

        int low = 1, high = b - a + 1, mid = 0, min = Integer.MAX_VALUE;
        for (int i = 0; i < 25; i++) {
            mid = (low + high) / 2;
            if (check(mid)) {
                high = mid  - 1;
                min = Math.min(min, mid);
            } else
                low = mid + 1;
        }
        System.out.println(min == Integer.MAX_VALUE ? -1 : min);
    }

    private static boolean check(int l) {
        for (int i = a; i <= b - l + 1; i++) {
            int v = primes[i + l -1] - primes[i - 1];
            if (v < k)
                return false;
        }
        return true;
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedOutputStream;
import java.util.StringTokenizer;
import java.io.Closeable;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.Flushable;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	static class TaskAdapter implements Runnable {
		@Override
		public void run() {
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			Input in = new Input(inputStream);
			Output out = new Output(outputStream);
			CPrimesOnInterval solver = new CPrimesOnInterval();
			solver.solve(1, in, out);
			out.close();
		}
	}

	public static void main(String[] args) throws Exception {
		Thread thread = new Thread(null, new TaskAdapter(), "", 1<<29);
		thread.start();
		thread.join();
	}
	static class CPrimesOnInterval {
		boolean[] prime;
		int a;
		int b;
		int k;

		public CPrimesOnInterval() {
		}

		public boolean valid(int x) {
			int sum = 0;
			for(int i = a; i<a+x; i++) {
				if(prime[i]) {
					sum += 1;
				}
			}
			for(int i = a; i<=b-x; i++) {
				if(sum<k) {
					return false;
				}
				if(prime[i]) {
					sum--;
				}
				if(prime[i+x]) {
					sum++;
				}
			}
			return sum>=k;
		}

		public void solve(int kase, Input in, Output pw) {
			a = in.nextInt();
			b = in.nextInt();
			k = in.nextInt();
			ArrayList<Integer> al = Utilities.sieve(b);
			prime = new boolean[b+1];
			for(int i: al) {
				prime[i] = true;
			}
			int sum = 0;
			for(int i = a; i<=b; i++) {
				if(prime[i]) {
					sum++;
				}
			}
			if(sum<k) {
				pw.println(-1);
				return;
			}
			int l = 1, r = b-a+1;
			while(l<r) {
				int mid = l+r >> 1;
				if(valid(mid)) {
					r = mid;
				}else {
					l = mid+1;
				}
			}
			pw.println(l);
		}

	}

	static class Input {
		BufferedReader br;
		StringTokenizer st;

		public Input(InputStream is) {
			this(is, 1<<20);
		}

		public Input(InputStream is, int bs) {
			br = new BufferedReader(new InputStreamReader(is), bs);
			st = null;
		}

		public boolean hasNext() {
			try {
				while(st==null||!st.hasMoreTokens()) {
					String s = br.readLine();
					if(s==null) {
						return false;
					}
					st = new StringTokenizer(s);
				}
				return true;
			}catch(Exception e) {
				return false;
			}
		}

		public String next() {
			if(!hasNext()) {
				throw new InputMismatchException();
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}

	static class Output implements Closeable, Flushable {
		public StringBuilder sb;
		public OutputStream os;
		public int BUFFER_SIZE;
		public boolean autoFlush;
		public String LineSeparator;

		public Output(OutputStream os) {
			this(os, 1<<16);
		}

		public Output(OutputStream os, int bs) {
			BUFFER_SIZE = bs;
			sb = new StringBuilder(BUFFER_SIZE);
			this.os = new BufferedOutputStream(os, 1<<17);
			autoFlush = false;
			LineSeparator = System.lineSeparator();
		}

		public void println(int i) {
			println(String.valueOf(i));
		}

		public void println(String s) {
			sb.append(s);
			println();
			if(autoFlush) {
				flush();
			}else if(sb.length()>BUFFER_SIZE >> 1) {
				flushToBuffer();
			}
		}

		public void println() {
			sb.append(LineSeparator);
		}

		private void flushToBuffer() {
			try {
				os.write(sb.toString().getBytes());
			}catch(IOException e) {
				e.printStackTrace();
			}
			sb = new StringBuilder(BUFFER_SIZE);
		}

		public void flush() {
			try {
				flushToBuffer();
				os.flush();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public void close() {
			flush();
			try {
				os.close();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

	}

	static class Utilities {
		public static ArrayList<Integer> sieve(int n) {
			ArrayList<Integer> ans = new ArrayList<>();
			boolean[] prime = new boolean[n+1];
			Arrays.fill(prime, true);
			for(int i = 2; i<=n; i++) {
				if(prime[i]) {
					ans.add(i);
				}
				if((long) i*i>n) {
					continue;
				}
				for(int j = i*i; j<=n; j += i) {
					prime[j] = false;
				}
			}
			return ans;
		}

	}
}

import java.util.*;
import java.io.*;
public class C {
	List<Integer> prime;

	public void solve() throws IOException {
		prime = new ArrayList<Integer>();
		prime.add(2);
		int[] sum = new int[1200001];
		sum[2] = 1;
		for(int i = 3; i < sum.length; i++){
			if( i%2 == 0 ){
				sum[i] = sum[i-1];
				continue;
			}
			boolean flag = true;
			for(Integer p : prime){
				if( p > Math.sqrt(i) ){
					prime.add(i);
					break;
				}
				if( i%p == 0 ){
					flag = false;
					break;
				}
			}
			if( flag ){
				sum[i] = sum[i-1]+1;
			} else {
				sum[i] = sum[i-1];
			}
		}

		int a = nextInt();
		int b = nextInt();
		int k = nextInt();
		for(int i = a; i <= b; i++){
			if( sum[i]-sum[a-1] >= k ){
				int ans = i-a+1;
				int id = a+1;
				while( id <= b-ans+1 ){
					if( sum[id+ans-1]-sum[id-1] >= k ){
						id++;
					} else {
						ans++;
					}
				}
				writer.println(ans);
				return;
			}
		}
		writer.println(-1);
	}

	public static void main(String[] args) throws IOException {
		new C().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class C
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;
	String FInput="";

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public void readFInput()
	{
		for(;;)
		{
			try
			{
				readNextLine();
				FInput+=line+" ";
			}
			catch(Exception e)
			{
				break;
			}
		}
		inputParser = new StringTokenizer(FInput, " ");
	}

	long NextLong()
    {
            String n = inputParser.nextToken();

            long val = Long.parseLong(n);

            return val;
    }

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new C(filePath);
	}

	boolean [] [] q;

	public C(String inputFile)
	{
		openInput(inputFile);

		readNextLine();
		int a=NextInt(),b=NextInt(),k=NextInt();

		boolean [] p = new boolean[1000001];

		for(int i=2; i<p.length; i++)p[i]=true;
		int cnt=0;

		int [] cnts = new int [p.length];

		for(int i=2; i<p.length; i++)
		{
			cnts[i]=cnt;
			if(!p[i])continue;
			for(int j=i*2; j<p.length; j+=i)
				p[j]=false;
			cnts[i]=++cnt;
		}
		int ret=-1;

		int d=b-a+1;

		boolean ok=true;
		for(int x=a; x<=b-d+1&&ok; x++)
		{
			if(cnts[x+d-1]-cnts[x-1]<k)ok=false;
		}
		if(ok)
		{
			ret=d;

			int c=1;

			while(c<d)
			{
				int m=(c+d)/2;
				ok=true;
				for(int x=a; x<=b-m+1&&ok; x++)
				{
					if(cnts[x+m-1]-cnts[x-1]<k)ok=false;
				}

				if(ok)d=m;
				else c=m+1;

			}
			ret=d;
		}

		System.out.println(ret);

        closeInput();
	}

}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
    public class Main
    {
        public static void main(String[] args)
        {
        Scanner sc =new Scanner(System.in);
        int i=0;
        int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
        int l=0;
        int[] mas = new int[b-a+3];
        i=1;mas[0]=a-1;
        for(int j=a;j<=b;j++)
        {
            if(prost(j)){mas[i]=j;i++;}
        }

        mas[i]=b+1;
        int maxx=0;

        for(int max=c;max<=i;max++)
        {

            maxx=Math.max(maxx, mas[max]-mas[max-c]);
        }
        if(maxx>=mas[i]-mas[0] || maxx==0)maxx=-1;
        System.out.println(maxx);
    }
        public static boolean prost(int lol)
        {
            boolean lal=true;

            for(int i=2;i<=Math.sqrt(lol);i++)
            {
                if(lol%i==0){lal=false;break;}
            }
            if(lol==1)lal=false;
            return lal;
        }
    }

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Tolik
 */
public class Codeforces1 {
    public static int[] readIntMas1(){
        Scanner sc = new Scanner(System.in);
        int[] input = new int[sc.nextInt()];
        for (int i = 0; i < input.length; i ++){
            input[i] = sc.nextInt();
        }
        return input;
    }

    public static int[][] readIntMas2(){
        Scanner sc = new Scanner(System.in);
        int[][] input = new int[sc.nextInt()][sc.nextInt()];
        for (int i = 0; i < input.length; i ++){
            for (int j = 0; j < input[j].length; j++){
                input[i][j] = sc.nextInt();
            }
        }
        return input;
    }

    public static int[] readStringToIntWithDigits(){
        Scanner sc = new Scanner(System.in);
        String tmp = sc.nextLine();
        int[] input = new int[tmp.length()];
        for (int i = 0; i < input.length; i++){
            input[i] = Integer.parseInt(String.valueOf(tmp.charAt(i)));
        }
        return input;
    }

    public static int[] readStringToIntWithoutDigits(){
        Scanner sc = new Scanner(System.in);
        String tmp = sc.nextLine();
        int[] input = new int[tmp.length()];
        for (int i = 0; i < input.length; i++){
            if (tmp.charAt(i) == 'a'){
                input[i] = 0;
            } else{
                input[i] = 1;
            }
        }
        return input;
    }

    public static int[][] readStringToIntWithoutDigits2(int n, int m){
        Scanner sc = new Scanner(System.in);
        int[][] input = new int[n][m];
        for (int i = 0; i < n; i++){
            String tmp = sc.nextLine();
            for (int j = 0; j < n; j++){
                if (tmp.charAt(j) == 'a'){
                    input[i][j] = 0;
                } else{
                    input[i][j] = 1;
                }
            }
        }
        return input;
    }

    static int g(int x){
        return x ^ (x >> 1);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 1000001;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        boolean[] ar = new boolean[n];
        for (int i = 0; i < n; i ++){
            ar[i] = true;
        }
        ar[0] = ar[1] = false;
        for (int i=2; i<n; ++i)
    if (ar[i])
        if (((long)i) * i < n)
            for (long j=i*i; j<n; j+=i)
                ar[(int)j] = false;
        int[]ar2 = new int [n];
        ar2[0]  = 0;
        for (int i = 1; i < n; i++){
            if (ar[i]){
                ar2[i] = ar2[i-1] + 1;
            } else{
                ar2[i] = ar2[i-1];
            }
        }
        boolean flag = false;

        int l = k;
            boolean flag2 = true;
            int x = a;
            for (; x <= b - l + 1; x++){
                for (; x>=a && l <= b - a + 1 && ar2[x+l-1] - ar2[x - 1] < k;l++, x--);
           /*     if (ar2[x+l-1] - ar2[x - 1] < k){
                    flag2 = false;
                    break;
                }*/

            }
                if (l > b- a + 1){
                    l = b - a + 1;
                }
                if (x > b - l + 1){
                    x = b-l+1;
                }
                if (l <= b - a + 1  && (ar2[x+l-1] - ar2[x - 1] >= k)){
                    flag = true;
                    System.out.println(l);
                }
       if (!flag){
           System.out.println(-1);
       }

    }
}

import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class Solution {

    static final int[] first10Primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        LinkedList<Integer> primes = primesBetween(a, b);
        primes.addFirst(a - 1);
        primes.addLast(b + 1);
        if (k > primes.size()) {
            System.out.println(-1);
            return;
        }
        Iterator<Integer> head = primes.subList(k, primes.size()).iterator();
        Iterator<Integer> tail = primes.iterator();
        int l = -1;
        while (head.hasNext())
            l = Math.max(l, head.next() - tail.next());
        System.out.println((l <= b - a + 1) ? l : -1);
    }

    private static LinkedList<Integer> primesBetween(int a, int b) {

        LinkedList<Integer> tmp = new LinkedList<>();

        for (int i = 9; i >= 0; i--) {
            int p = first10Primes[i];
            if (p > b)
                continue;
            if (p >= a)
                tmp.addFirst(p);
            else break;
        }

        if (b <= 30)
            return tmp;

        // Sieve of Eratosthenes
        int[] sieve = new int[b + 1];
        for (int i = 0; i <= 30; i++)
            sieve[i] = 1;
        for (int p : first10Primes) {
            sieve[p] = 0;
            for (int i = p * p; i <= b; i += p)
                sieve[i] = 1;
        }
        for (int i = 31; i <= b; i += 2) {
            if (sieve[i] == 1)
                continue;
            int j = i * i;
            if (j > b)
                break;
            for ( ; j > 0 && j <= b; j += i)
                sieve[j] = 1;
        }
        for (int i = Math.max(a % 2 == 0 ? a + 1 : a, 31); i <= b; i += 2)
            if (sieve[i] == 0)
                tmp.addLast(i);

        return tmp;
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * @author mohanad
 *
 */
public class P5_Div2_237C {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		BufferedReader bf= new BufferedReader(new InputStreamReader(System.in));
		String abk []=bf.readLine().split(" ");
		int a=Integer.parseInt(abk[0]);
		int b=Integer.parseInt(abk[1]);
		int k=Integer.parseInt(abk[2]);

		ArrayList<Integer> list = new ArrayList<>();
		for (int i=a ; i<=b ; ++i){
			if (prime(i)){
				list.add(i);
			}
		}
		if (list.size()<k){
			System.out.println(-1);
		}
//		else if (list.size()==k){
//			System.out.println(b-a+1);
//		}
		else{
			System.out.println(getL(list, k ,a,b));
		}

	}

	static boolean prime (int num){

		if (num==2)
			return true;
		else if (num<2 || num%2==0)
			return false;

		for (int i = 3 ; i*i<=num ; ++i){
			if (num%i==0){
				return false;
			}
		}
		return true;

	}

	static int getL (ArrayList<Integer> list , int k , int a ,int b){
		int ln=list.size();
		int ans=0;

		if (k==ln){
			return Math.max(b-list.get(0)+1, list.get(ln-1)-a+1);
		}
//		int s=k==1?k+1:k;
//		for (int i = 0 , j=i+s-1; i < ln &&j<ln ; ++i,++j){
//			ans=Math.max(ans, list.get(j)-list.get(i));
//		}

		for (int i = 0 ; i+k<ln ; ++i){
			ans=Math.max(ans, list.get(i+k)-list.get(i));
		}

//		if (k!=1)
//		++ans;
		ans=Math.max(list.get(k-1)+1-a,ans );
		ans=Math.max(b-list.get(ln-k)+1,ans );
		return ans ;

	}

}

import java.util.*;
public class cf237c {
  static int a, b, k, MAX = 1000010;
  static boolean[] isPrime = new boolean[MAX];
  public static void main(String[] args) {
    Arrays.fill(isPrime, true);
    isPrime[0] = isPrime[1] = false;
    for(int i=0; i<MAX; i++)
      if(isPrime[i])
        for(int j=i+i; j<MAX; j+=i)
          isPrime[j] = false;
    Scanner in = new Scanner(System.in);
    a = in.nextInt();
    b = in.nextInt();
    k = in.nextInt();
    int hi = (b-a)+1;
    int lo = 1;
    if(!ok(hi)) {
      System.out.println("-1");
      return;
    }
    while(hi - lo > 2) {
      int m = (hi+lo)/2;
      if(!ok(m)) lo = m;
      else hi = m;
    }
    while(!ok(lo)) lo++;
    System.out.println(lo);
  }
  static boolean ok(int l) {
    int count = 0;
    for(int i=a; i<a+l; i++)
      if(isPrime[i])
        count++;
    if(count < k) return false;
    for(int i=a+l; i<=b; i++) {
      if(isPrime[i-l]) count--;
      if(isPrime[i]) count++;
      if(count < k) return false;
    }
    return true;
  }
}

import java.io.*;
import java.util.*;

public class ProblemC {
    InputReader in; PrintWriter out;
    void solve() {
        boolean isPrime[] = new boolean[1010000];
        Arrays.fill(isPrime, true);
        isPrime[0] = false;
        isPrime[1] = false;
        for (int i = 2; i <= 1000000; i++)
            if (isPrime[i])
                for (int j = i + i; j <= 1000000; j += i)
                    isPrime[j] = false;
        int sum[] = new int[1001000];
        sum[0] = 0;
        for (int i = 1; i <= 1000000; i++)
            if (isPrime[i])
                sum[i] = sum[i - 1] + 1;
            else
                sum[i] = sum[i - 1];
//      for (int i = 0; i < 20; i++)
//          out.println(i + " " + isPrime[i] + " " + sum[i]);
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();
        int lg = 0;
        int rg = b - a + 1;
        int mi = 0;
        if (sum[b] - sum[a - 1] < k) {
            out.println(-1);
            return;
        }
        while (rg - lg > 1) {
            mi = (lg + rg + 1) / 2;
            boolean ok = true;
            for (int from = a; from + mi - 1 <= b; from++)
                if (sum[from + mi - 1] - sum[from - 1] < k) {
                    ok = false;
                    break;
                }
            if (ok)
                rg = mi;
            else
                lg = mi;
        }
        out.println(rg);
    }

    ProblemC(){
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        try {
            if (oj) {
                in = new InputReader(System.in);
                out = new PrintWriter(System.out);
            }
            else {
                Writer w = new FileWriter("output.txt");
                in = new InputReader(new FileReader("input.txt"));
                out = new PrintWriter(w);
            }
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
        solve();
        out.close();
    }
    public static void main(String[] args){
        new ProblemC();
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public InputReader(FileReader fr) {
        reader = new BufferedReader(fr);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }

}

import java.io.*;
import java.util.*;

public class C {

    public static void main(String[] args) throws IOException {
        MyScan ms = new MyScan();

        int a = ms.nextInt();
        int b = ms.nextInt();
        int k = ms.nextInt();

        boolean[] q = new boolean[b + 1];
        for (int i = 0; i <= b; i++)
            q[i] = true;

        for (int i = 2; i * i <= b; i++)
            if (q[i])
                for (int j = i * i; j <= b; j += i)
                    q[j] = false;

        q[1] = false;
        int s = 0, l = 0;

        while (s < k && l < b - a + 1) {
            if (q[a + l])
                s++;
            l++;
        }

        if (s < k) {
            System.out.print(-1);
            return;
        }

        for (int i = l + a; i <= b; i++) {
            if (q[i] && !q[i - l])
                s++;
            else if (!q[i] && q[i - l])
                if (s == k)
                    l++;
                else
                    s--;
        }

        System.out.print(l);

    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        else
            return gcd(b, a % b);
    }

    private static class MyScan {
        BufferedReader br;
        StringTokenizer st;

        public MyScan(String path) throws IOException {
            br = new BufferedReader(new FileReader(new File(path)));
        }

        public MyScan() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }
    }
}

//package codeforces;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class A implements Closeable {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    A() throws IOException {
//        reader = new BufferedReader(new FileReader("input.txt"));
//        writer = new PrintWriter(new FileWriter("output.txt"));
    }

    StringTokenizer stringTokenizer;

    String next() throws IOException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            stringTokenizer = new StringTokenizer(reader.readLine());
        }
        return stringTokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    private int MOD = 1000 * 1000 * 1000 + 7;

    int sum(int a, int b) {
        a += b;
        return a >= MOD ? a - MOD : a;
    }

    int product(int a, int b) {
        return (int) (1l * a * b % MOD);
    }

    int pow(int x, int k) {
        int result = 1;
        while (k > 0) {
            if (k % 2 == 1) {
                result = product(result, x);
            }
            x = product(x, x);
            k /= 2;
        }
        return result;
    }

    int inv(int x) {
        return pow(x, MOD - 2);
    }

    void solve() throws IOException {
        int a = nextInt(), b = nextInt(), k = nextInt();
        boolean[] isPrime = new boolean[b + 1];
        Arrays.fill(isPrime, true);
        isPrime[1] = false;
        for(int i = 2; i * i < isPrime.length; i++) {
            if(isPrime[i]) {
                for(int j = i * i; j < isPrime.length; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        int lo = 0, hi = b - a + 2;
        while(hi - lo > 1) {
            int m = lo + hi >> 1;
            int r = a;
            int primesCount = 0;
            for(int i = 0; i < m; i++) {
                if(isPrime[r++]) {
                    primesCount++;
                }
            }
            boolean ok = primesCount >= k;
            while(r <= b) {
                primesCount += isPrime[r] ? 1 : 0;
                primesCount -= isPrime[r - m] ? 1 : 0;
                r++;
                ok = ok && (primesCount >= k);
            }
            if(ok) {
                hi = m;
            } else {
                lo = m;
            }
        }
        if(hi == b - a + 2) {
            hi = -1;
        }
        writer.println(hi);
    }

    public static void main(String[] args) throws IOException {
        try (A a = new A()) {
            a.solve();
        }
    }

    @Override
    public void close() throws IOException {
        reader.close();
        writer.close();
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner scn = new Scanner(System.in);

		int a = scn.nextInt();
		int b = scn.nextInt();

		int k = scn.nextInt();

		ArrayList<Integer> list = SOE(b, a);
		int n = list.size();

		if (n < k) {
			System.out.println(-1);
			return;
		}

		int j = b;
		int lidx = 0;
		int ridx = k - 1;
		int l = 0;
		int i = 0;
		for (i = a; i <= j; i++) {

			l = Math.max(list.get(ridx) - i + 1, l);

			j = b - l + 1;
			if (i == list.get(lidx)) {
				lidx++;
				ridx++;

			}

			if (ridx == n) {
				break;
			}
		}

		if (i <= j) {
			lidx--;
			l = Math.max(b - list.get(lidx) + 1, l);
		}
		System.out.println(l);

	}

	public static ArrayList<Integer> SOE(int n, int a) {

		boolean arr[] = new boolean[n + 1];

		Arrays.fill(arr, true);

		for (int table = 2; table * table <= n; table++) {

			if (arr[table] == true) {

				for (int mult = 2; mult * table <= n; mult++) {
					arr[table * mult] = false;
				}
			}
		}

		arr[0] = arr[1] = false;

		ArrayList<Integer> list = new ArrayList<>();

		for (int i = a; i < n + 1; i++) {

			if (arr[i])
				list.add(i);
		}

		return list;

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class PrimesOnInt {

	public static void main(String[] args) throws IOException {

		int a,b,k,lc,ln;
		String input;
		int N = (int) Math.pow(10, 6);

		int[] Primes = new int[N + 1];
		int count = 0;

	    	for (int i = 2; i <= N; i++) {

	    		if(Primes[i] == 0){
	    			count++;
	    			Primes[i] = count;
	    			for (int j = 2; i*j <= N; j++) {
	    				Primes[i*j] = count;
	                }
	    		} else { Primes[i] = count;}

	        }

	   BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	   input = reader.readLine();

	   String[] abc = input.split(" ");

	   a = Integer.parseInt(abc[0]);
	   b = Integer.parseInt(abc[1]);
	   k = Integer.parseInt(abc[2]);

	   if(!Check(a,b,b-a+1,k,Primes)) System.out.println(-1);
	   else {
		   lc = b-a+1;
		   ln = 1;
		   System.out.println(Finder(a,b,k,Primes,lc,ln));
		   }

	}

	public static boolean Check(int a, int b, int l, int k, int[] Primes){

		if(Primes[b] - Primes[b-l] < k)
			return false;
		else{
			for(int i = a; i < b-l+1; i++){
				if(Primes[i+l-1] - Primes[i-1] < k) return false;
			}
			return true;
		}

	}

	public static int Finder(int a, int b, int k, int[] Primes, int lc, int ln){

		if(k == 0)
			return 1;
		if(a == b && k == 1)
			return isPrime(a,Primes);

		if(lc == ln + 1)
			return lc;

		int l = (lc - ln)/2 + ln;

		if(Check(a, b, l, k, Primes)){
			lc = l;
		} else ln = l;

		return Finder(a, b, k, Primes, lc, ln);

	}

	public static int isPrime(int a, int[] Primes){

		if(Primes[a] - Primes[a-1] == 0) return -1;
		else return 1;
	}

}

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	static class InputReader{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int readInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return readString();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object...objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void printLine(Object...objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}

		public void flush() {
			writer.flush();
		}

		}

    static class IOUtils {

		public static int[] readIntArray(InputReader in, int size) {
			int[] array = new int[size];
			for (int i = 0; i < size; i++)
				array[i] = in.readInt();
			return array;
		}
    }
    //static int a, b, k;
    static int m;
    static OutputWriter out;
    static InputReader in;
    static boolean[] c;
    static ArrayList<Integer> list;
    public static void main (String[] args) throws java.lang.Exception
	{
	    out = new OutputWriter(System.out);
		in = new InputReader(System.in);
        c = new boolean[1000001];
        c[1] = true;
        for(int i=3; i*i<=1000000; i+=2){
            int j = i;
            if(c[j]==false){j+=i; while(j<=1000000){c[j]=true; j+=i;}}
        }
        int a = in.readInt(); int b = in.readInt(); int k = in.readInt();
        list = new ArrayList<Integer>(); list.add(a-1);
        for(int i=a; i<=b; i++)if((i%2!=0||i==2)&&!c[i])list.add(i);
        int max = -1;
        for(int i=k; i<list.size(); i++){
            max = Math.max(max, list.get(i)-list.get(i-k));
        }
        if(list.size()>=k+1)max = Math.max(max, b-list.get(list.size()-k)+1);
        //for(int i=0; i<list.size(); i++)out.print(list.get(i)+" ");
        //out.printLine();
        out.print(max);
        out.flush();
        out.close();
	}

   public static int gcd(int aaa, int bbb){
        //b is greater
        if(aaa>bbb){int temp = aaa; aaa = bbb; bbb = temp;}
        if(bbb%aaa==0)return aaa;
        return gcd(bbb%aaa, aaa);
    }
	public static void add(int index, int value, int[] b){
	    while(index < b.length){
	        b[index] += value;
	        index = index + (index & (-index));
	    }
	}

	public static int getSum(int index, int [] b){
	    int sum = 0;
	    while(index > 0){
	        sum += b[index];
	        index = index - (index&(-index));
	    }
	    return sum;
	}

	public static void printArray(int[] a){
	    for(int i=1; i<a.length; i++)out.print(a[i]+" ");
	    out.printLine("---------");
	}

	static class Pair implements Comparable<Pair>{
	    int s;
	    //int d;
	    int len;
	    public Pair(int a, int c){
	        s = a; len = c;
	    }
	    public int compareTo(Pair p){
	        if(this.len > p.len)return 1;
	        else if(this.len < p.len)return -1;
	        return 0;
	    }
	}
}

import java.util.*;
import java.io.*;

		public class codeforces
		{
			public static void main(String[] args)
			{
				InputReader in = new InputReader(System.in);
				PrintWriter pw = new PrintWriter(System.out);

				int a = in.nextInt();
				int b = in.nextInt();
				int k = in.nextInt();
				long[] Prime = new long[b+1];

				Prime = sieve(b+1);

				int i = a, j = a, l = 1;

				while(j<=b)
				{
					if(Prime[j]-Prime[i-1]>=k)
					{
						i++;
						j++;
					}
					else
					{
						j++;
						l = j - i + 1;
					}
				}

				if(l>b-a+1)
					l = -1;

				pw.println(l);

				pw.flush();
				pw.close();
			}

			public static long[] sieve(int n)
			{
				boolean[] isPrime = new boolean[n];
				long[] Prime = new long[n];

				for(int i=1;i<n;i++)
					isPrime[i] = true;

				isPrime[0] = false;
				isPrime[1] = false;

				for(int i=2;i*i<n;i++)
				{
					if(isPrime[i] == true)
					{
						for(int j=(i*i);j<n;j+=i)
							isPrime[j] = false;
					}
				}

				for(int i=1;i<n;i++)
				{
					if(isPrime[i])
						Prime[i] = Prime[i-1] + 1;
					else
						Prime[i] = Prime[i-1];
				}

				return Prime;
			}

			static class pair implements Comparable<pair>
			{
				Long x, y;
				pair(long x,long y)
				{
					this.x=x;
					this.y=y;
				}

				public int compareTo(pair o) {
					int result = x.compareTo(o.x);
					if(result==0)
						result = y.compareTo(o.y);

					return result;
				}

				public String toString()
				{
					return x+" "+y;
				}

				public boolean equals(Object o)
				{
					if (o instanceof pair)
				    {
						pair p = (pair)o;
						return p.x == x && p.y == y ;
					}
					return false;
				}

				public int hashCode()
				{
					return new Long(x).hashCode()*31 + new Long(y).hashCode();
				}
			}

			static class InputReader
			{

				private final InputStream stream;
				private final byte[] buf = new byte[8192];
				private int curChar, snumChars;
				private SpaceCharFilter filter;

				public InputReader(InputStream stream)
				{
					this.stream = stream;
				}

				public int snext()
				{
					if (snumChars == -1)
						throw new InputMismatchException();
					if (curChar >= snumChars)
					{
						curChar = 0;
						try
						{
							snumChars = stream.read(buf);
						}
						catch (IOException e)
						{
							throw new InputMismatchException();
						}
						if (snumChars <= 0)
							return -1;
					}
					return buf[curChar++];
				}

				public int nextInt()
			    {
					int c = snext();
					while (isSpaceChar(c))
					{
						c = snext();
					}
					int sgn = 1;
					if (c == '-')
				    {
						sgn = -1;
						c = snext();
					}
					int res = 0;
					do
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = snext();
					} while (!isSpaceChar(c));
					return res * sgn;
				}

				public long nextLong()
			    {
					int c = snext();
					while (isSpaceChar(c))
					{
						c = snext();
					}
					int sgn = 1;
					if (c == '-')
					{
						sgn = -1;
						c = snext();
					}
					long res = 0;
					do
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = snext();
					} while (!isSpaceChar(c));
					return res * sgn;
				}

				public int[] nextIntArray(int n)
				{
					int a[] = new int[n];
					for (int i = 0; i < n; i++)
					{
						a[i] = nextInt();
					}
					return a;
				}

				public String readString()
			    {
					int c = snext();
					while (isSpaceChar(c))
					{
						c = snext();
					}
					StringBuilder res = new StringBuilder();
					do
					{
						res.appendCodePoint(c);
						c = snext();
					} while (!isSpaceChar(c));
					return res.toString();
				}

				public String nextLine()
				{
					int c = snext();
					while (isSpaceChar(c))
						c = snext();
					StringBuilder res = new StringBuilder();
					do
					{
						res.appendCodePoint(c);
						c = snext();
					} while (!isEndOfLine(c));
					return res.toString();
				}

				public boolean isSpaceChar(int c)
				{
					if (filter != null)
						return filter.isSpaceChar(c);
					return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				}

				private boolean isEndOfLine(int c)
				{
					return c == '\n' || c == '\r' || c == -1;
				}

				public interface SpaceCharFilter
			    {
					public boolean isSpaceChar(int ch);
				}
			}

			static class CodeX {
	        public static void sort(long arr[]) {
	            merge_sort(arr, 0, arr.length - 1);
	        }

	        private static void merge_sort(long A[], long start, long end) {
	            if (start < end) {
	                long mid = (start + end) / 2;
	                merge_sort(A, start, mid);
	                merge_sort(A, mid + 1, end);
	                merge(A, start, mid, end);
	            }

	        }

	        private static void merge(long A[], long start,long mid, long end) {
	            long p = start, q = mid + 1;
	            long Arr[] = new long[(int)(end - start + 1)];
	            long k = 0;

	            for (int i = (int)start; i <= end; i++) {
	                if (p > mid)
	                    Arr[(int)k++] = A[(int)q++];

	                else if (q > end)
	                    Arr[(int)k++] = A[(int)p++];

	                else if (A[(int)p] < A[(int)q])
	                    Arr[(int)k++] = A[(int)p++];

	                else
	                    Arr[(int)k++] = A[(int)q++];
	            }
	            for (int i = 0; i < k; i++) {
	                A[(int)start++] = Arr[i];
	            }

	        }

	    }
		}

import java.util.*;
import java.io.*;

public class c {

   boolean is(int n) {
      if(n < 2) return false;
      for(int i = 2; i * i <= n; ++i)
         if(n % i == 0)
            return false;
      return true;
   }

   private void solve() throws Exception {
      //BufferedReader br = new BufferedReader(new FileReader("c.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] pa = br.readLine().split(" ");
      int a = Integer.parseInt(pa[0]), b = Integer.parseInt(pa[1]), k = Integer.parseInt(pa[2]), r = 0, s = 0;
      int[] su = new int[b + 1];

      for(int i = 1; i <= b; ++i) {
         if(is(i))
            su[i] = su[i - 1] + 1;
         else
            su[i] = su[i - 1];
      }

      for(int i = a; i <= b; ++i) {
         int c = 0, j = i, d = 0;
         /*for(; j <= b; ++j) {
           c = su[j] - su[i - 1];
           if(c == k)
           break;
           }*/
         int lo = i, hi = b, cu = su[i] - su[i - 1];
         while(lo <= hi) {
            int mid = (hi + lo) / 2, di = su[mid] - su[i];
            if(cu + di < k)
               lo = mid + 1;
            else
               hi = mid - 1;
         }
         s = Math.max(s, lo - i + 1);
         r = Math.max(r, j - i + 1);
      }

      int lo = 0, hi = b - a + 2;

      while(lo <= hi) {
         int mid = (hi + lo) / 2;
         boolean is = true;
         for(int i = a - 1; i + mid <= b; ++i)
            if(su[i + mid] - su[i] < k)
               is = false;

         if(!is)
            lo = mid + 1;
         else
            hi = mid - 1;
      }

      if(lo <= b - a + 1)
         System.out.println(lo);
      else
         System.out.println(-1);
   }

   public static void main(String[] args) throws Exception {
      new c().solve();
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }

}

import java.util.*;
import java.io.*;

public class Codeforces {

    static int arr[];

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        int a = Reader.nextInt(), b = Reader.nextInt(), k = Reader.nextInt();
        boolean p[] = new boolean[b+1];
        arr = new int[b+1];
        int count = 0;

        for(int i = 2; i  <= b; i++){
            if(!p[i]){
                count++;
                for(int j = i; (long)(j) * i <= b; j++)
                    p[j * i] = true;
            }

            arr[i] = count;
        }

        int last = b-a+1, first = 1, ans = -1;
        while(last >= first){
            int mid = (last + first) / 2;
            if(check(a,b,mid,k)){
                last = mid - 1;
                ans = mid;
            }

            else
                first = mid + 1;
        }

        if(ans == -1)
            System.out.println("-1");

        else
         System.out.println(ans);
   }

   public static boolean check(int a, int b, int l, int k){
       int lim = b - l + 1;

       for(int i = a; i <= lim; i++)
           if(arr[i + l - 1] - arr[i-1] < k)
              return false;

       return true;
   }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /**
     * call this method to initialize reader for InputStream
     */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static byte nextByte() throws IOException {

        return Byte.parseByte(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

import java.util.*;
import java.io.*;

public class c {

   boolean is(int n) {
      if(n < 2) return false;
      for(int i = 2; i * i <= n; ++i)
         if(n % i == 0)
            return false;
      return true;
   }

   private void solve() throws Exception {
      //BufferedReader br = new BufferedReader(new FileReader("c.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] pa = br.readLine().split(" ");
      int a = Integer.parseInt(pa[0]), b = Integer.parseInt(pa[1]), k = Integer.parseInt(pa[2]), r = 0, s = 0;
      int[] su = new int[b + 1];

      for(int i = 1; i <= b; ++i) {
         if(is(i))
            su[i] = su[i - 1] + 1;
         else
            su[i] = su[i - 1];
      }

      int lo = 0, hi = b - a + 2;

      while(lo <= hi) {
         int mid = (hi + lo) / 2;
         boolean is = true;
         for(int i = a - 1; i + mid <= b; ++i)
            if(su[i + mid] - su[i] < k)
               is = false;

         if(!is)
            lo = mid + 1;
         else
            hi = mid - 1;
      }

      if(lo <= b - a + 1)
         System.out.println(lo);
      else
         System.out.println(-1);
   }

   public static void main(String[] args) throws Exception {
      new c().solve();
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }

}

import java.util.*;
import java.io.*;

public class c {

   boolean is(int n) {
      if(n < 2) return false;
      for(int i = 2; i * i <= n; ++i)
         if(n % i == 0)
            return false;
      return true;
   }

   private void solve() throws Exception {
      //BufferedReader br = new BufferedReader(new FileReader("c.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] pa = br.readLine().split(" ");
      int a = Integer.parseInt(pa[0]), b = Integer.parseInt(pa[1]), k = Integer.parseInt(pa[2]), r = 0, s = 0;
      int[] su = new int[b + 1];

      for(int i = 1; i <= b; ++i) {
         if(is(i))
            su[i] = su[i - 1] + 1;
         else
            su[i] = su[i - 1];
      }

      for(int i = a; i <= b; ++i) {
         int c = 0, j = i, d = 0;
         /*for(; j <= b; ++j) {
           c = su[j] - su[i - 1];
           if(c == k)
           break;
           }*/
         int lo = i, hi = b, cu = su[i] - su[i - 1];
         while(lo <= hi) {
            int mid = (hi + lo) / 2, di = su[mid] - su[i];
            if(cu + di < k)
               lo = mid + 1;
            else
               hi = mid - 1;
         }
         s = Math.max(s, lo - i + 1);
         r = Math.max(r, j - i + 1);
      }

      if(s > b - a + 1)
         System.out.print(-1);
      else
         System.out.print(s);
   }

   public static void main(String[] args) throws Exception {
      new c().solve();
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }

}

import java.io.*;
import java.util.*;
import java.math.*;
public class B {
    void solve() throws IOException{
        int maxN = (int) 2.1e6;
        int [] A = new int[maxN];
        int [] S = new int[maxN];
        A[0] = 1;
        A[1] = 1;
        for (int i = 2, sum = 0; i < maxN; i++) {
            if (A[i] == 0) {
                for (int j = i*2; j < maxN; j += i) {
                    A[j] = 1;
                }
                sum++;
            //    out.println(i);
            //    out.flush();
            }
            S[i] = sum;
        }

        int a, b, k;
        a = nextInt();
        b = nextInt();
        k = nextInt();
        int l = 0;
        int r = b - a + 2;
        while (r - l > 1) {
            int m = (r + l) / 2;
            boolean ok = true;
            for (int x = a; x <= b - m + 1; x++) {
                if (S[x + m - 1] - S[x - 1] < k) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                r = m;
            } else {
                l = m;
            }
        }
        if (r > b - a + 1) {
            out.print(-1);
            return;
        } else {
            out.print(r);
        }
    }
    public static void main(String [] args) throws IOException{
        (new B()).run();
    }
    StreamTokenizer in;
    PrintWriter out;
    void run () throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
    }
    int nextInt () throws IOException {
        in.nextToken();
        return (int)in.nval;
    }
    long nextLong () throws IOException {
        in.nextToken();
        return (long)in.nval;
    }
    String nextStr () throws IOException {
        in.nextToken();
        return (String)in.sval;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Codeforces237C {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer init = new StringTokenizer(br.readLine());
		int a = Integer.parseInt(init.nextToken());
		int b = Integer.parseInt(init.nextToken());
		int k = Integer.parseInt(init.nextToken());

		HashMap<Integer,Integer> hmPrime = new HashMap<Integer,Integer>();
		HashMap<Integer,Integer> hmPos = new HashMap<Integer,Integer>();
		int x = 0;

		for (int i = 0; i < b-a+1; i++) {
			hmPos.put(i, x);
			if (isPrime(a+i)){
				hmPrime.put(x, i);
				x++;
			}

		}

		if(x<k) {
			System.out.println(-1);
			return;
		}
		int l;
		if(hmPrime.get(x-k) != null) l = b-a-hmPrime.get(x-k)+1;
		else l = b-a+1;
		for (int i = 0; i < hmPrime.get(x-1); i++) {
			if(hmPos.get(i) != null && hmPrime.get(hmPos.get(i) + k-1) != null){
				if(hmPrime.get(hmPos.get(i) + k-1)-i+1 > l){
					l = hmPrime.get(hmPos.get(i) + k-1)-i+1;
				}
			}
		}
		System.out.println(l);
	}

	static boolean isPrime(int n) {
	//check if n is a multiple of 2 or if its 1
		if(n==1) return false;
		if(n==2) return true;
		if(n%2==0) return false;
		    //if not, then just check the odds
	    for(int i=3;i*i<=n;i+=2) {
	        if(n%i==0)
	            return false;
	    }
		return true;
	}
}

import java.io.*;
import java.util.*;

public class Example {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(in.readLine());
            } catch (Exception e) {
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
    static boolean[] prime = new boolean[10001001];
    static int[] sum = new int[1001001];
    static int a, b, k;

    public void run() throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        a = nextInt();
        b = nextInt();
        k = nextInt();
        Arrays.fill(prime, true);
        prime[1] = false;
        int m = (int) Math.sqrt(b) + 1;
        for (int i = 4; i <= b; i += 2) {
            prime[i] = false;
        }
        for (int i = 3; i <= m; i++) {
            if (prime[i]) {
                for (int j = i * i; j <= b && j > 1; j += 2 * i) {
                    prime[j] = false;
                }
            }
        }
        for (int i = 2; i <= b+100; i++) {
            sum[i] = sum[i - 1];
            if (prime[i]) {
                sum[i]++;
            }
        }
        int begin = 1;
        int end = b - a + 1;
        int l = (begin + end) / 2;

        while (true) {
            boolean ok = f(l);
            if (ok && !f(l - 1)) {
                break;
            }
            if (l == end) {
                l = -1;
                break;
            }
            if (ok) {
                end = l;
            } else {
                begin = l;
            }
            l = (int) Math.round((begin + end + 0.0) / 2.0);
        }
        out.println(l);
        out.flush();
        out.close();
        in.close();
    }

    public static boolean f(int l) {
        for (int x = a; x <= b - l + 1; x++) {
            if (sum[x+l-1] - sum[x-1] < k) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) throws Exception {
        new Example().run();
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Sunits789
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        boolean isPrime[]=new boolean[1000010];
        int ans=0;
        Library.sieve(isPrime);
        isPrime[1]=false;
        int a=in.nextInt();
        int b=in.nextInt();
        int k=in.nextInt();
        int l=1;
        int h=b-a+1;
        while(l<(h-1)){
            ans=(l+h)/2;
            boolean ok=getOk(isPrime,a,b,ans,k);
            if(ok){
                h=ans;
            }
            else{
                l=ans;
            }
        }
        int total=0;
        for(int i=a;i<=b;i++){
            if(isPrime[i]){
                total++;
            }
        }
        if(total>=k){
            out.println(h);
        }
        else{
            out.println(-1);
        }
    }

    private boolean getOk(boolean isPrime[],int a, int b, int ans,int k){
        int pc=0;
        for(int i=0;i<ans;i++){
            if(isPrime[i+a]){
                pc++;
            }
        }
        if(pc<k){
            return false;
        }
        int head=a+ans;
        int tail=a;
        for(;head<=b;tail++,head++){
            if(isPrime[tail]){
                pc--;
            }
            if(isPrime[head]){
                pc++;
            }
            if(pc<k){
                return false;
            }
        }
        return true;
    }
}

class InputReader{
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }
    public String next(){
        while (tokenizer == null||!tokenizer.hasMoreTokens()){
            try{
                tokenizer = new StringTokenizer(reader.readLine());
            }
            catch (IOException e){
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt(){
        return Integer.parseInt(next());
    }

    }

class Library{

    public static void sieve(boolean arr[]){
        Arrays.fill(arr,true);
        int n=arr.length;
        for(int i=2;i<n;i++){
            if(arr[i]){
                for(int mul=2;mul*i<n;mul++){
                    arr[mul*i]=false;
                }
            }
        }
    }

    }

import java.util.Scanner;

public class C {
    static int[] accumPrimeCnt = new int[1000001];

    public static void sieve() {
        accumPrimeCnt[2] = 1;
        int sqrt = (int) (Math.sqrt(1000000) + 1);
        int[] marks = new int[15630];
        for (int i = 3; i <= sqrt; i += 2) {
            if ((marks[i >> 6] & (1 << ((i >> 1) & 31))) == 0) {
                for (int j = i * i; j <= 1000000; j += (i << 1)) {
                    marks[j >> 6] |= (1 << ((j >> 1) & 31));
                }
            }
        }
        for (int i = 3; i <= 1000000; i += 1) {
            if (i%2==1&&(marks[i >> 6] & (1 << ((i >> 1) & 31))) == 0) {
                accumPrimeCnt[i] = 1 + accumPrimeCnt[i - 1];
            } else {
                accumPrimeCnt[i] = accumPrimeCnt[i - 1];
            }
        }
    }

    public static boolean valid(int st, int end, int len, int k) {
        for (int i = end; i - len + 1 >= st; i--) {
            if (accumPrimeCnt[i] - accumPrimeCnt[i - len] < k)
                return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sieve();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int l = 1, h = b - a + 2, mid;
        while (l < h) {
            mid = l + (h - l) / 2;
            if (!valid(a, b, mid, k)) {
                l = mid + 1;
            } else {
                h = mid;
            }
        }
        if (l == b - a + 2)
            System.out.println(-1);
        else
            System.out.println(l);
        sc.close();
    }
}

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static void sieve()
    {
        Arrays.fill(prime, true);
        for(int i=2;i*i<=1000001;i++)
            if(prime[i])
                for(int j=i*i;j<1000001;j+=i)
                    prime[j] = false;
        for(int i=2;i<1000001;i++)
            if(prime[i])
                arr[i] = arr[i-1]+1;
            else
                arr[i] = arr[i-1];
    }
    static boolean[] prime;
    static int[] arr;
    static int a, b, k;
    static void zap() throws IOException {
        arr = new int[1000001];
        prime = new boolean[1000001];
        sieve();
        a = nextInt(); b = nextInt(); k = nextInt();
        out.println(lower_bound(1,b-a+1,k));
    }
    static int lower_bound(int l, int r, int k)
    {
        int res = -1;
        while(l <= r)
        {
            int mid = (l+r)/2;
            if(f(mid) == false)
                l = mid + 1;
            else
            {
                res = mid;
                r = mid - 1;
            }
        }
        return res;
    }
    static boolean f(int offset)
    {
        for(int p = a; p <= b - offset + 1; p++)
            if(arr[p+offset-1] - arr[p-1] < k)
                return false;
        return true;
    }

    static BufferedReader br;
    static StringTokenizer st;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        InputStream input = System.in;
        //InputStream input = new FileInputStream("fileIn.in");
        br = new BufferedReader(new InputStreamReader(input));
        out = new PrintWriter(System.out);
        //out = new PrintWriter(new FileOutputStream("fileOut.out"));
        zap();
        out.close();
    }

    static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    static String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }
}

import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		StreamInputReader in = new StreamInputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public static final int MAXN = 1000005;
    int[] sum;
    int a;
    int b;
    int k;
	public void solve(int testNumber, StreamInputReader in, PrintWriter out) {
        a = in.nextInt();
        b = in.nextInt();
        k = in.nextInt();
        boolean[] isPrime = new boolean[MAXN];
        Arrays.fill(isPrime, true);
        isPrime[1] = false;
        for(int i = 2; i < MAXN; i++)
            if(isPrime[i]) {
                if((long)i * i < MAXN)
                    for(int j = i * i; j < MAXN; j += i)
                        isPrime[j] = false;
            }

        sum = new int[MAXN];
        for(int i = a; i <= b; i++)
            sum[i] = sum[i - 1] + (isPrime[i] ? 1 : 0);

        int st = 1;
        int dr = b - a + 1;
        int m = -1;
        int ans = MAXN;
        while(st <= dr) {
            m = (st + dr) / 2;
            if(good(m)) {
                ans = Math.min(ans, m);
                dr = m - 1;
            }
            else st = m + 1;
        }

        if(ans == MAXN)
            out.print(-1);
        else
            out.print(ans);
	}

    private boolean good(int len) {
        for(int i = a; i <= b - len + 1; i++)
            if(sum[i + len - 1] - sum[i - 1] < k)
                return false;
        return true;
    }
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar, numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    }

abstract class InputReader {

    public abstract int read();

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		solver.solve(in, out);
		out.close();
	}
}

class Solver {
	public void solve(InputReader in, PrintWriter out) {
		int a = in.nextInt();
		int b = in.nextInt();
		int k = in.nextInt();
		boolean[] np = new boolean[b + 2];
		np[0] = true;
		np[1] = true;
		for (int i = 2; i <= b; ++i) {
			if (np[i])
				continue;
			for (int j = 2 * i; j <= b; j += i) {
				np[j] = true;
			}
		}
		int l = 0;
		int r = b - a + 1;
		while (l < r - 1) {
			int m = (l + r) / 2;
			int cp = 0;
			for (int i = a; i < a + m; ++i){
				if (!np[i])
					cp++;
			}
			boolean ind = true;
			for (int i = a; i < b - m + 2; ++i) {
				if (cp < k) {
					ind = false;
					break;
				}
				if (!np[i]) {
					cp--;
				}
				if (i + m <= b && !np[i + m]) {
					cp++;
				}
			}
			if (ind) {
				r = m;
			} else
				l = m;
		}
		int cp = 0;
		for (int i = a; i < a + r; ++i){
			if (!np[i])
				cp++;
		}
		boolean ind = true;
		for (int i = a; i < b - r + 2; ++i) {
			if (cp < k) {
				ind = false;
				break;
			}
			if (!np[i]) {
				cp--;
			}
			if (i + r <= b && !np[i + r]) {
				cp++;
			}
		}
		if (!ind) {
			out.println(-1);
		} else {
			out.println(r);
		}
	}
}

class InputReader {
	private BufferedReader reader;
	private StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

import java.util.*;
import java.io.*;

public class Main{

    int []s;
    int a,b,k;

    public void run(){
	Scanner in = new Scanner(System.in);
	a = in.nextInt();
	b = in.nextInt();
	k = in.nextInt();

	s = new int[1000001];
	Arrays.fill(s, 1);
	s[0] = s[1] = 0;
	for(int i=2;i<s.length;i++){
	    if (s[i] == 1){
		if (1L*i*i < s.length){
		    for(int j=i*i;j<s.length;j+=i){
			s[j] = 0;
		    }
		}
	    }
	}

	for(int i=1;i<s.length;i++){
	    s[i]+=s[i-1];
	}
	if (s[b] - s[a-1] < k){
	    System.out.println(-1);
	    return;
	}

	int l = 0;
	int r = b - a + 2;
	while(r - l > 1){
	    int m = (l+r)/2;
	    int c = calc(m);
	    if (c >= k){
		r = m;
	    }else{
		l = m;
	    }
	}

	if (r < b - a + 2){
	    System.out.println(r);
	}else{
	    System.out.println(-1);
	}
    }

    private int calc(int l){
	int ret = Integer.MAX_VALUE;
	for(int i=a, j=a+l-1;j<=b;i++,j++){
	    ret = Math.min(ret, s[j] - s[i-1]);
	}
	return ret;
    }

    public static void main(String args[]){
	new Main().run();
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class C {

	private final int MAX = 1000010;

	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

	int a, b, k;
	boolean[] isComposite = new boolean[MAX];
	int[] cntPrimes = new int[MAX];

	private void readInput() {
		try {
			String[] tokens = reader.readLine().split(" ");
			a = Integer.parseInt(tokens[0]);
			b = Integer.parseInt(tokens[1]);
			k = Integer.parseInt(tokens[2]);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void crossAll(int number) {
		int temp = number + number;
		while (temp <= b) {
			isComposite[temp] = true;
			temp += number;
		}
	}

	private void generatePrimes() {
		isComposite[1] = true;
		crossAll(2);
		crossAll(3);

		int possiblePrime = 5;
		while (possiblePrime <= b) {
			if (!isComposite[possiblePrime]) {
				crossAll(possiblePrime);
			}

			if (possiblePrime + 2 <= b && !isComposite[possiblePrime + 2]) {
				crossAll(possiblePrime + 2);
			}

			possiblePrime += 6;
		}

		cntPrimes[0] = 0;
		cntPrimes[1] = 0;
		cntPrimes[2] = 1;
		for (int i = 3; i <= b; i++) {
			cntPrimes[i] += cntPrimes[i - 1] + (isComposite[i] ? 0 : 1);
		}
	}

	private boolean possible(int l) {
		for (int start = a; start <= b - l + 1; start++) {
			int end = start + l - 1;
			if (cntPrimes[end] - cntPrimes[start - 1] < k) {
				return false;
			}
		}

		return true;
	}

	private void binarySearch() {
		int left = 0, right = b - a + 2;
		while(left + 1 < right) {
			int mid = left + right; mid = mid >> 1;
			if (possible(mid)) {
				right = mid;
			} else {
				left = mid;
			}
		}

		if (right < b - a + 2 && right >= 1) {
			System.out.println(right);
		} else {
			System.out.println("-1");
		}
	}

	private void solve() {
		readInput();
		generatePrimes();

		binarySearch();

	}

	public static void main(String[] args) {
		new C().solve();
	}
}

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class taskC {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        taskC solver = new taskC();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: "
                    + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        // TODO
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        // in = new BufferedReader(new FileReader("input.txt"));
        // out = new PrintWriter(new FileWriter("output.txt"));
    }

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null)
                return null;
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }

    public int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    int a, b, k, l;
    boolean prime[] = new boolean[(int) (1e6 + 10)];

    public void solve() throws NumberFormatException, IOException {
        int N = 1000005;
        int kpr = 0;
        int lp[] = new int[N + 1], pr[] = new int[N];
        Arrays.fill(lp, 0);
        for (int i = 2; i <= N; ++i) {
            if (lp[i] == 0) {
                lp[i] = i;
                pr[kpr++] = i;
            }
            for (int j = 0; j < kpr && pr[j] <= lp[i]
                    && 1L * i * pr[j] <= N * 1L; ++j)
                lp[i * pr[j]] = pr[j];
        }

        a = nextInt();
        b = nextInt();
        k = nextInt();
        for (int i = 0; i <= b+3; i++) {
            prime[i] = ((lp[i] == 0) || (lp[i]==i));
        }

        prime[1] = false;
        prime[2] = true;

        int left = a, right = a, cnt = 0;
        while (right <= b && cnt < k) {
            if (prime[right]) {
                cnt++;
            }
            right++;
        }
        if (cnt < k) {
            out.println(-1);
            return;
        }
        int answ = -left + right;
        while (right <= b) {
            if (prime[left]) {
                cnt--;
            }
            left++;

            while (right <= b && cnt < k) {
                if (prime[right]) {
                    cnt++;
                }
                right++;
            }
            if (cnt<k){
                left--;
            }
            answ = Math.max(answ, right-left);
        }

        out.println(answ);

    }

    public void close() {
        out.flush();
        out.close();
    }
}

/**
 * Created by kapilkrishnakumar on 11/4/15.
 */
import java.util.*;
public class PrimeInterval {

    public static void main(String[] args) {
        Scanner me = new Scanner(System.in);

        final int cs = 1 << 20;

        int u[] = new int[cs];
        int sum[] = new int[cs];
        for (int i = 2; i < cs; i++)
            if (u[i] == 0)
                for (int j = i + i; j < cs; j += i)
                    u[j] = 1;

        for (int i = 2; i < cs; i++)
            sum[i] = sum[i - 1] + (u[i] ^ 1);

        //for(int i = 1 ; i < 10 ; i ++)
        //	out.println(sum[i]);

        int a, b, k;

        a = me.nextInt();
        b = me.nextInt();
        k = me.nextInt();

        int low = 1, high = b - a + 1, mid, best_ok = 12345678;

        for (int tt = 1; tt < 25; tt++) {
            mid = (low + high) >> 1;

            int ok = 1;

            for (int i = a; i <= b - mid + 1; i++)
                if (sum[i + mid - 1] - sum[i - 1] < k) {
                    ok = 0;
                    break;
                }

            if (ok == 1) {
                if (mid < best_ok)
                    best_ok = mid;
                high = mid;
            } else low = mid + 1;
        }

        if (best_ok == 12345678)
            best_ok = -1;
        System.out.println(best_ok);
    }
}

import java.util.*;
import java.math.*;
import java.io.*;

public class C146
	{
	public static void main(String args[]) throws IOException
		{

		Scanner c=new Scanner(System.in);
		int a=c.nextInt();
		int b=c.nextInt();
		int k=c.nextInt();

		boolean[] p=eratos(1000001);
		int[] no=new int[1000001];
		no[0]=0;
		no[1]=0;

		for(int i=2;i<1000001;i++)
			{
			if(p[i])
				no[i]=no[i-1]+1;
			else
				no[i]=no[i-1];
			}

		int min=1000001;
		int n=0;
		int flag=0;
			int start=1;
			int end=b-a+1;
			int c1=0;
			while (start <= end)
				{
		        int l = (start + end) / 2;
				for(int x=a;x<=b-l+1;x++)
					{
					n=0;
//					for(int i=x;i<=x+l-1;i++)
//						{
//						if(p[i])
//							n++;
//						}
					n=no[x+l-1]-no[x-1];

					if(n>=k)
						c1++;
					}

					if(c1==(b-l+1-a+1))
						{
						if(l<min)
							min=l;
						end = l - 1;
						flag=1;
						}
					else
						{
						start = l + 1;
						}
					c1=0;
				}

		if(flag==0)
		System.out.println(-1);
		else
			System.out.println(min);

		}

	/*
	 * Fills the boolean A[i] with true iff i is a prime.
	 * Works in .35 seconds for N=10000000.
	 *
	 * For primes upto 100, pass N=101.
	 */
private static boolean[] eratos(int N)
	{
	boolean A[]=new boolean[N];
	Arrays.fill(A,true);
	A[0]=false;
	A[1]=false;
	for(int i=2;i<N;i++)
		{
		if(A[i]==true)	//a prime
			{
			int num=i+i;
			while(num<N)
				{
				A[num]=false;
				num+=i;
				}
			}
		}
	return A;
	}

}

//must declare new classes here

import java.io.*;
import java.util.*;

public class pr147C implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer str;

	public void solve() throws IOException {
		int a = nextInt();
		int b = nextInt();
		int k = nextInt();
		boolean p[] = new boolean[1000001];
		Arrays.fill(p, true);
		p[1] = false;
		for (int i = 2; i < 1001; i++) {
			if (p[i])
				for (int j = i + i; j < 1000001; j += i)
					p[j] = false;
		}
		int c = 0;
		for (int i = a; i < b + 1; i++)
			if (p[i])
				c++;
		if (c < k)
			out.println(-1);
		else {
			c = 0;
			int l = a;
			int r = a;
			if (p[l])
				c++;
			while (r < b) {
				while ((c < k) && (r < b)) {
					r++;
					if (p[r])
						c++;
				}
				if (r < b) {
					l++;
					if (p[l - 1])
						c--;
					r++;
					if (p[r])
						c++;
				}
			}
			while (c < k) {
				l--;
				if (p[l])
					c++;
			}
			int ans = r - l + 1;
			if (ans <= b - a + 1)
				out.println(ans);
			else
				out.println(-1);
		}
	}

	public String nextToken() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			str = new StringTokenizer(in.readLine());
		}
		return str.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (IOException e) {
		}
	}

	public static void main(String[] args) {
		new Thread(new pr147C()).start();
	}
}

import java.io.*;
import java.util.*;

public class TaskC implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() {
        while (stok == null || !stok.hasMoreTokens()) {
            try {
                stok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return stok.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(nextToken());
    }

    long nextLong() {
        return Long.parseLong(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }

    boolean isSimple(int x) {
        if (x == 1) {
            return false;
        }
        int s = (int) Math.floor(Math.sqrt(x));
        for (int i = 2; i <= s; i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }

    void solve() throws IOException {
        int a = nextInt(), b = nextInt(), k = nextInt();
        boolean[] pr = new boolean[b + 1];
        for (int i = a; i <= b; i++) {
            pr[i] = isSimple(i);
        }
        int i1 = a, i2 = a, t = pr[a] ? 1 : 0;
        int ans = -1;
        while (true) {
            while (t < k && i2 < b) {
                i2++;
                if (pr[i2]) {
                    t++;
                }
            }
            if (t == k) {
                ans = Math.max(ans, i2 - i1 + 1);
            } else {
                if (i1 != a) {
                    ans = Math.max(ans, b - i1 + 2);
                }
                break;
            }
            if (pr[i1]) {
                t--;
            }
            i1++;
        }
        out.println(ans);
    }

    public void run() {
        final String filename = "taskc";
        try {
            try {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            } catch (Exception e1) {
                try {
                    in = new BufferedReader(new FileReader("input.txt"));
                    out = new PrintWriter("output.txt");
                } catch (Exception e2) {
                    in = new BufferedReader(new InputStreamReader(System.in));
                    out = new PrintWriter(System.out);
                }
            }
            solve();
            in.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public static void main(String[] args) {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception ingore) {
        }
        new Thread(new TaskC()).start();
    }
}

import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a=in.nextInt(),b=in.nextInt(),k=in.nextInt();
        boolean p[]= IntegerUtils.sieve(b+1);
        int c=0,i;
        ArrayList<Integer> x=new ArrayList<Integer>();
        for(i=a;i<=b;i++)
        {
            if(p[i])
            {
                c++;
                x.add(i);
            }
        }
        if(c<k)
        {
            out.println(-1);
            return;
        }
        //DebugUtils.print(c);
        int min=0;
        int start=0,end=k-1;

        min=x.get(k-1)-a+1;
        for(i=a;i<=b;i++)
        {

           /* if(x.size()-k==start)
            {

                if(p[i])
                    min=Math.max(min,b-i+1);
                else
                    min=Math.max(min,b-x.get(start)+1);
                continue;
            }  */

            if(i==x.get(start))
            {

                if(start==x.size()-k)
                {

                        min=Math.max(min,b-i+1);
                    break;
                }
                start++;
                min=Math.max(x.get(end)-i+1,min);
                end++;
                continue;
            }
            min=Math.max(x.get(end)-i+1,min);
        }

        out.println(min);
	}
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}

class IntegerUtils {
    public static boolean [] sieve(int n)
    {
        boolean prime[]=new boolean[n+1];
        Arrays.fill(prime,true);
        prime[0]=false;
        prime[1]=false;
        int sqrt=(int)Math.sqrt(n);
        for(int i=2;i<=sqrt;i++)
            if(prime[i])
                for(int k=i*i;k<=n;k+=i)
                    prime[k]=false;
        return prime;
    }

    }

import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					long time1 = System.currentTimeMillis();
					new Main().run();
					long time2 = System.currentTimeMillis();
					System.err.println("Time " + (time2 - time1) + " ms");
				} catch (Throwable e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		in.close();
		out.close();
	}

	final int MAXN = 1000000;

	boolean[] isPrime = new boolean[MAXN];

	private void solve() throws IOException {

		int[] sum = new int[MAXN + 1];

		fill(isPrime, true);
		for (int i = 2; i < MAXN; i++) {
			if (isPrime[i]) {
				sum[i] = 1;
				for (long j = 1L * i * i; j < MAXN; j += i)
					isPrime[(int) j] = false;
			}
		}

		for (int i = 1; i < sum.length; i++)
			sum[i] += sum[i - 1];

		int a = nextInt();
		int b = nextInt();
		int k = nextInt();

		int l = 1;
		int r = b - a + 1;

		int ans = -1;

		while (l <= r) {

			int m = (l + r) >> 1;

			int min = Integer.MAX_VALUE;
			for (int x = a; x <= b - m + 1 && min >= k; x++)
				min = min(min, sum[x + m - 1] - sum[x - 1]);

			if (min >= k) {
				r = m - 1;
				ans = m;
			} else {
				l = m + 1;
			}

		}

		out.println(ans);

	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}

import java.util.*;
public class C147 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean nt[] = new boolean[1000006];
        nt[1] = true;
        int j;
        for(int i=2;i<=1000000;i++){
            if(!nt[i]){
                j=2;
                while((i*j)<=1000000){
                    nt[i*j] = true;
                    j++;
                }
            }
        }
        int a, b, k;
        a = sc.nextInt();
        b = sc.nextInt();
        k = sc.nextInt();
        int nto[] = new int[1000006];
        int tngto[] = new int[1000006];
        int itngto = 0;
        nto[1] = 0;
        for(int i=a;i<=b;i++){
            if(!nt[i]){
                nto[i] = nto[i-1]+1;
                tngto[itngto] = i;
                itngto++;
            }else nto[i] = nto[i-1];
        }
        int snto = nto[b]-nto[a];
        if(!nt[a]) snto++;
        if(snto<k) System.out.println("-1");
        //if(snto==k) System.out.println(b-a+1);
        int l = 0;
        //System.out.println(snto);
        if(snto>=k){
            l = tngto[k-1]-a+1;
            for(int i=0;i<itngto-k;i++){
                if(tngto[i+k-1]-tngto[i]+1>l) l = tngto[i+k-1]-tngto[i]+1;
                if(tngto[i+k]-tngto[i]>l) l = tngto[i+k]-tngto[i];
            }
            if(b-tngto[itngto-k]+1>l) l = b-tngto[itngto-k]+1;
            System.out.println(l);
        }
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class P237_Primes_on_Interval {

	static int N = 1000000+1;
	static int a;
	static int b;
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		StringBuilder sb = new StringBuilder();
		StringTokenizer st;
		while((line = bf.readLine()) != null){
			sb.append(line+"\n");
		}
		st = new StringTokenizer(sb.toString());

		a = Integer.parseInt(st.nextToken());
		b = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		int[] criba = criba();
		int[] cribaAcu = new int[N];
		cribaAcu[0] = 0;
		cribaAcu[1] = 0;
		for (int i = 2; i < N; i++) {
			cribaAcu[i] = cribaAcu[i-1] + criba[i];
		}

		//System.out.println(existeX(1, a, b, cribaAcu, k));
		int indice = busquedaBinaria(1, b - a + 2, criba, cribaAcu, k);
		if(indice == b-a+1){
			//System.out.println(cribaAcu[b]);
			//System.out.println(cribaAcu[a-1]);
			if( cribaAcu[b] - cribaAcu[a-1] < k)
				System.out.println(-1);
			else
				System.out.println(indice);
		}else{
			System.out.println(indice);
		}

	}
	private static int busquedaBinaria(int i, int j, int[] criba, int[] cribaAcu, int k) {
		if(j - i <= 1)
			return i;
		int m = (i + j - 1) / 2;
		if(existeX(m, cribaAcu, k))
			return busquedaBinaria(i, m + 1, criba, cribaAcu, k);
		return busquedaBinaria(m + 1, j, criba, cribaAcu, k);
	}

	private static boolean existeX(int l, int[] cribaAcu, int k) {
		for (int x = a; x <= b-l+1; x++) {
			if(cribaAcu[x+l-1] - cribaAcu[x-1] < k)
				return false;
		}
		return true;
	}

	private static int[] criba() {
		int[] criba = new int[N];
		int i;
		for (i = 0; i < N; i++) {
			criba[i] = 1;
		}
		for (i = 2; i < (int)Math.sqrt(N); i++) {
			if(criba[i] == 1){
				for (int j = i; j*i < criba.length; j++) {
					criba[i*j] = 0;
				}
			}
		}
		return criba;
	}

}

import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main
{
    static StringTokenizer st=new StringTokenizer("");
    static BufferedReader br;
    ///////////////////////////////////////////////////////////////////////////////////

    public static void main(String args[]) throws FileNotFoundException, IOException, Exception
    {
        //Scanner in =new Scanner(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        //Scanner in=new Scanner(System.in);
        br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        //StringTokenizer st;//=new StringTokenizer(br.readLine());
        //////////////////////////////////////////////////////////////////////////////////////

        boolean primes[]=new boolean[1000001];
        primes[0]=true;
        primes[1]=true;
        for(int i=2;i*i<1000001;i++)
        {
            if(!primes[i])
                for(int j=i*i;j<1000001;j+=i)
                    primes[j]=true;
        }
        int a=ni(),b=ni(),k=ni();
        int total=0;
        for(int i=a;i<=b;i++)
            if(!primes[i])total++;
        if(total<k)
        {
            out.print(-1);
            out.close();
            return ;
        }
        int arr[]=new int[total];
        total=0;
        for(int i=a;i<=b;i++)
            if(!primes[i])arr[total++]=i;
        int max=0;
        max=Math.max(arr[k-1]-a+1,b-arr[total-k]+1);
        for(int i=k;i<total;i++)
            max=Math.max(max,arr[i]-arr[i-k]);
        out.print(max);

        //////////////////////////////////////////////////////////////////////////////////////
	out.close();
    }

    ///////////////////////////////////////////////////////////////////////////////

    private static long gcd(long a,long b)
    {
        if(b==0)
            return a;
        return gcd(b,a%b);
    }
    private static class pair implements Comparable<pair>
    {
        int first;
        int second;
        pair()
        {
            first=0;
            second=0;
        }
        pair(int f,int s)
        {
            first=f;
            second=s;
        }

        public int compareTo(pair o)
        {
            if(first+second >  o.first+o.second)
                return 1;
            else if(first+second < o.first+o.second)
                return -1;
            else
                return 0;
        }
    }

    public static Integer ni() throws Exception
    {
        if(!st.hasMoreTokens())
            st=new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }
    public static BigInteger nb()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return BigInteger.valueOf(Long.parseLong(st.nextToken()));
    }
    public static Long nl() throws Exception
    {
        if(!st.hasMoreTokens())
            st=new StringTokenizer(br.readLine());
        return Long.parseLong(st.nextToken());
    }
    public static Double nd()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return Double.parseDouble(st.nextToken());
    }
    public static String ns()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.math.*;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

}

class Task {

    final int maxn = 1_000_010;
    boolean pr[] = new boolean[maxn];
    int sum[] = new int[maxn];

    boolean can(int a, int b, int l, int k) {
        for(int i = a; i + l - 1 <= b; ++i) {
            if(sum[i + l - 1] - sum[i - 1] < k) {
                return false;
            }
        }
        return true;
    }

    public void solve(FastReader in, PrintWriter out) throws IOException {
        for(int i = 2; i < maxn; ++i) {
            pr[i] = true;
        }
        for(int i = 2; i < maxn; ++i) {
            sum[i] = sum[i - 1] + (pr[i] == true ? 1 : 0);
            if(!pr[i]) continue;
            for(int j = 2 * i; j < maxn; j += i)
                pr[j] = false;
        }
        int a = in.nextInt(), b = in.nextInt(), k = in.nextInt();
        int l = 1, r = b - a + 1;
        while(l < r - 1) {
            int m = (l + r) / 2;
            if(can(a, b, m, k)) {
                r = m;
            } else {
                l = m;
            }
        }
        if(!can(a, b, b - a + 1, k)) {
            out.println(-1);
        } else if(can(a, b, l, k)) {
            out.println(l);
        } else {
            out.println(r);
        }
    }

}

class FastReader {

    BufferedReader in;
    StringBuilder sb = new StringBuilder();

    public FastReader(BufferedReader in) {
        this.in = in;
    }

    public String next() throws IOException {
        sb.setLength(0);
        while(true) {
            int c = in.read();
            if(c == -1) {
                return null;
            }
            if(" \n\r\t".indexOf(c) == -1) {
                sb.append((char)c);
                break;
            }
        }
        while(true) {
            int c = in.read();
            if(c == -1 || " \n\r\t".indexOf(c) != -1) {
                break;
            }
            sb.append((char)c);
        }
        return sb.toString();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

}

import java.util.Arrays;
import java.util.Scanner;

public class I {
	static primeSieve PS;
	static int A,B,K;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();

		PS = new primeSieve(B+B+10);

		int low = K;
		int high = B-A+1;

		int mid = (low+high)/2;
		int ans = -1;

		while(low<=high){
			mid = (low+high)/2;
			if(F(mid)){
				ans = mid;
				high = mid - 1;
			}
			else {
				low = mid+1;
			}
		}

		System.out.println(ans);

	}

	private static boolean F(int L) {
		int count = 0;
		for(int a=A;a<A+L;a++){
			if(PS.isPrime(a))count++;
		}
		if(count<K)return false;
		for(int b=A+L;b<=B;b++){
			if(PS.isPrime(b-L))count--;
			if(PS.isPrime(b))count++;
			if(count<K)return false;
		}
		return true;
	}

	static class primeSieve {
	int[] prime;
	primeSieve(int n){
		prime = new int[n+1];
		prime[1] = -1;
		int m = (int)Math.sqrt(n);
		for(int i=2;i<=m;i++)
			if(prime[i]==0)
				for(int k=i*i;k<=n;k+=i)
					if(prime[k]==0)
						prime[k]=i;
	}
	boolean isPrime(int n){
		return prime[n]==0;
	}
}

}

import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out,true);
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static boolean[] isPrime;
    static int[] npr;
    static int a,b,k;

    public static void main(String[] args) throws Exception {
        a = nextInt(); b = nextInt(); k = nextInt();
        getPrimes(b);
        int count = 0;
        for(int i = 2;i < isPrime.length;i++) if(i >= a && i <= b && isPrime[i]) count++;
        if(count < k) {out.println(-1);return;}
        npr = new int[isPrime.length];
        for(int i = 1;i < npr.length;i++) npr[i] = npr[i-1]+(isPrime[i]?1:0);
        out.println(func(0,b-a+1));
    }

    public static int func(int l, int r) {
        if(l == r || l+1 == r) {
            if(check(l)) return l;
            return r;
        }
        int mid = (l+r)/2;
        if(check(mid)) return func(l,mid);
        return func(mid,r);
    }

    public static boolean check(int l) {
        for(int i = a;i <= b-l+1;i++) {
            if(npr[i+l-1]-npr[i-1] < k) return false;
        }
        return true;
    }

    public static void getPrimes(int b) {
        isPrime = new boolean[b+1];
        Arrays.fill(isPrime,true);
        isPrime[0] = isPrime[1] = false;
        for(int i = 2;i*i <= b;i++) if(isPrime[i]) for(int j = i*i;j <= b;j+=i) isPrime[j] = false;
    }

    public static int nextInt() throws Exception {
        if(st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static long nextLong() throws Exception {
        if(st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Long.parseLong(st.nextToken());
    }

    public static double nextDouble() throws Exception {
        if(st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Double.parseDouble(st.nextToken());
    }

    public static String nextToken() throws Exception {
        if(st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class c {
	void do_solve() throws NumberFormatException, IOException {
		int a = _int();
		int b = _int();

		int k = _int();

		boolean sos[] = new boolean[b+1];
		sos[0] = sos[1] = true;
		for(int i = 2; i <= b; i++) {
			if (!sos[i]) {
				for(int j = 2 * i; j <= b; j += i)
					sos[j] = true;
			}
		}

		int l = 0;
		int now = 0;
		for(int i = a; i + l - 1 <= b; i++) {
			while (now < k && i + l <= b) {
				if (!sos[i + l])
					now++;
				l++;
			}

			if (now < k && i == a) {
				out.println(-1);
				return;
			}

			if (now < k) {
				l++;
			}

			if (!sos[i]) {
				now--;
			}
			if (i + l <= b) {
				if (!sos[i + l]) {
					now++;
				}
			}
		}
		out.println(l);
	}

	void debug(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}

	void mainProgram() throws NumberFormatException, IOException {
		/*
		test("c.in");
		 */
		try {
			init(true, "c");
		} catch (Exception e) {
			init(false, "");
		}
		boolean multy = false;

		if (!multy) {
			while (in.ready() || st.hasMoreTokens()) {
				do_solve();
			}
		} else {
			for (int T = _int(); T > 0; --T) {
				do_solve();
			}
		}
		out.close();
	}

	void init(boolean FILE, String name) throws NumberFormatException,
			IOException {
		Locale.setDefault(Locale.US);
		if (FILE) {
			in = new BufferedReader(new FileReader(name + ".in"));
			out = new PrintWriter(name + ".out");
		} else {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}
		st = new StringTokenizer("");
	}

	void test(String name) throws IOException {
		out = new PrintWriter(new File(name));

		out.close();
	}

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		long T = System.currentTimeMillis();
		new c().mainProgram();
		System.err.println("Time of working: "
				+ (System.currentTimeMillis() - T) + " ms");
	}

	String _token() throws IOException {
		while (in.ready() && !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		if (st.hasMoreTokens())
			return st.nextToken();
		return "";
	}

	BigInteger add(BigInteger A, BigInteger B) {
		return A.add(B);
	}

	BigInteger mult(BigInteger A, BigInteger B) {
		return A.multiply(B);
	}

	BigInteger sub(BigInteger A, BigInteger B) {
		return A.subtract(B);
	}

	BigInteger div(BigInteger A, BigInteger B) {
		return A.divide(B);
	}

	BigInteger mi(BigInteger A) {
		return (BigInteger.ZERO).subtract(A);
	}

	BigInteger sq(BigInteger A) {
		return A.multiply(A);
	}

	BigInteger val(long a) {
		return BigInteger.valueOf(a);
	}

	int cmp(BigInteger a, BigInteger b) {
		return a.compareTo(b);
	}

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	int _int() throws NumberFormatException, IOException {
		return Integer.parseInt(_token());
	}

	long _long() throws NumberFormatException, IOException {
		return Long.parseLong(_token());
	}

	double _double() throws NumberFormatException, IOException {
		return Double.parseDouble(_token());
	}

	int gcd(int a, int b) {
		if (a < 0)
			a = -a;
		if (b < 0)
			b = -b;
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	long gcd(long a, long b) {
		if (a < 0)
			a = -a;
		if (b < 0)
			b = -b;
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	BigInteger gcd(BigInteger a, BigInteger b) {
		if (cmp(a, val(0)) < 0)
			a = mi(a);
		if (cmp(b, val(0)) < 0)
			b = mi(b);
		return a.gcd(b);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PrimesInterval {

	static int[] criba;
	static int[] np;
	static int count = 0;
	static int a;
	static int b;
	static int k;
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		a = Integer.parseInt(input[0]);
		b = Integer.parseInt(input[1]);
		k = Integer.parseInt(input[2]);

		criba = new int[b+1];
		np = new int[b+1];
		armarCriba();
		int l = buscar();
		System.out.println(l);
	}

	static void armarCriba(){
		for (int i = 2; i < b+1; i++){
			if (criba[i] == 0){ count++; }
			np[i] = count;
			//System.out.println("np["+i+"] = "+count);
			for (int j = 2; i*j < b+1; j++){
				criba[i*j] = i;
			}
		}
	}

	static int buscar(){
		int lo = 1;
		int hi = b-a+1;
		int mid;
		while (lo < hi){
			mid = lo + (hi-lo)/2;
			if (sirve(mid)){
				if (!sirve(mid-1)){ return mid; }
				hi = mid - 1;
			}
			else {
				if (sirve(mid+1)){ return mid+1; }
				lo = mid + 1;
			}
		}
		if ((lo == hi) && sirve(lo)){ return lo; }
		else { return -1; }
	}

	static boolean sirve(int m){
		//System.out.println("checking " + m);
		for (int i = a; i+m-1 <= b; i++){
			//System.out.println("np["+(i+m-1)+"] = " + np[i+m-1]);
			//System.out.println("np["+(i-1)+"] = " + np[i-1]);
			if (np[i+m-1] - np[i-1] < k){ return false; }
		}
		return true;
	}

}

import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class c {
    int maxn = 1001010;
    boolean isp[] = new boolean[maxn];
    int sum[] = new int[maxn];

    int getprim(int n) {
        int m = 1, cnt = 0;
        while (m * m < n)
            m++;
        Arrays.fill(isp, true);
        isp[1] = isp[0] = false;
        for (int i = 4; i <= n; i += 2)
            isp[i] = false;
        for (int i = 3; i <= m; i += 2)
            if (isp[i])
                for (int j = i * i; j <= n; j += 2 * i)
                    isp[j] = false;
        for (int i = 1; i<=n; i++)
            if (isp[i])
                sum[i] = sum[i - 1] + 1;
            else
                sum[i] = sum[i - 1];
        return cnt;
    }

    int a, b, k;

    boolean test(int mid) {
        for (int i = a; i + mid - 1 <= b; i++)
            if (sum[i + mid - 1] - sum[i - 1] < k)
                return false;
        return true;
    }

    void run() throws IOException {
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        b = scan.nextInt();
        k = scan.nextInt();
        getprim(b+100);
        int left = 1, right = b - a + 1, ans = -1;
        while (left <= right) {
            int mid = (left + right) >> 1;
            if (test(mid)) {
                right= mid- 1;
                ans = mid;
            } else
                left = mid +1;
        }
        System.out.println(ans);
    }
    public static void main(String[] args) throws IOException {
        new c().run();
    }
}

import java.io.*;
import java.util.*;
public class Main{
    static int atoi(String n){return Integer.parseInt(n);}
    static int a,b,k;
    static int cp[];
    static boolean[] criba(int n){
        int fin = (int)Math.sqrt(n)+1;
        boolean p[] = new boolean[n+1];
        p[0] = p[1] = true;
        for(int i=0;i<fin;i++)
            if(!p[i])
                for(int j=i*i;j<p.length;j+=i)
                    p[j] = true;
        return p;
    }
    static boolean puede(int l){
        if(l<k || b-l+1-a==-1)return false;
        for(int j=0;j<=b-l+1-a;j++){
            int suma = cp[a+j+l-1] - cp[a+j-1];
            //System.out.println(j+" "+suma+" ");
            //System.out.println();
            if(suma<k)return false;
        }
        //System.out.println("retorna true");
        return true;
    }
    static int bs(int cp[]){
        int low = 1, high = b-a+1;
        int last = -1;
        while(low<=high){
            int l = (low+high)>>1;
            //System.out.println("fijo con "+l);
            if(puede(l)){
                high = l-1;
                last = l;
            }
            else
                low = l+1;
        }
        return last;
    }
    public static void main(String jfkd[])throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String div[] = br.readLine().split(" ");
        a = atoi(div[0]);b=atoi(div[1]); k=atoi(div[2]);
        boolean p[] = criba(2*b+1);
        //for(int i=0;i<p.length;i++)
        //  if(!p[i])
        //      System.out.print(i+" ");
        //System.out.println();
        cp = new int[p.length];
        cp[0] = 0;
        for(int i=1;i<cp.length;i++)
            cp[i] += cp[i-1]+(!p[i]?1:0);
        System.out.println(bs(cp));
    }
}

import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class C {
	Scanner sc = new Scanner(System.in);
	void doIt()
	{
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		boolean	[] isprime = new boolean [b+1];
		Arrays.fill(isprime, true);
		isprime[0] = isprime[1] = false;
		for(int i = 0; i*i <= b; i++) {
			if(isprime[i]) {
				for(int j = i + i;  j <= b; j += i) {
					isprime[j] = false;
				}
			}
		}
		ArrayList<Integer> pos = new ArrayList<Integer>();
		pos.add(a-1);
		for(int i = a; i <= b; i++) {
			if(isprime[i]) pos.add(i);
		}
		pos.add(b+1);
		int ans = -1;
		for(int i = 0; i < pos.size(); i++) {
			if(i + k >= pos.size()) break;
			ans = max(ans, pos.get(i+k) - pos.get(i));
		}
		if(ans > b - a + 1) ans = -1;
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new C().doIt();
	}

}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author mdonaj
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();

        boolean[] primes = new boolean[b+10];
        Arrays.fill(primes, true);
        primes[0] = false;
        primes[1] = false;

        for(int i = 2; i <= b; ++i) {
            if(!primes[i])
                continue;
            int c = i;

            for(int j = i + c; j <= b; j += c)
                primes[j] = false;
        }

        int[] cnt = new int[b+1];
        int curr = 0;
        for(int i = 0; i <= b; ++i) {
            if(primes[i])
                curr++;
            cnt[i] = curr;
        }

        int l = -1;
        for(int i = a; i <= b; ++i) {
            if(a + l > b)
                break;

            int next = k+cnt[i];
            if(primes[i])
                next--;

            int idx = Arrays.binarySearch(cnt, next);
            if(idx < 0 && l > 0) {
                l = b-a+1;
                break;
            }

            if(idx < 0 || idx > b)
                break;

            if(idx != 0 && cnt[idx] == cnt[idx -1]) idx--;
            l = Math.max(l, idx - i + 1);
        }

        out.println(l);

	}
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static int a,b,k;
	static boolean[] isPrime;
	static void sieve()
	{
		isPrime = new boolean[100+(((int)1e6)<<1)];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; i++)
			if(isPrime[i])
				for(int j = i<<1 ; j<isPrime.length;j+=i)
					isPrime[j] = false;
	}
	static int solve()
	{
		int len = 0 , bound = b-a+1;
		int l = a,r=a, count = 0;
		while(l<=b-len+1)
		{
			if(r<=l)
			{
				r=l;
				count=0;
			}
			while((r<=l)||(count<k && r-l<=bound))
				if(isPrime[r++])count++;
			if(count!=k)
				return -1;
			if(isPrime[l])
				count--;
			len = Math.max(len, r-l++);
		}
		return (len>bound)?-1:len;
	}
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner((System.in));
		a = sc.nextInt();
		b = sc.nextInt();
		k = sc.nextInt();
		sieve();
		System.out.println(solve());
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(s));
		}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public boolean ready() throws IOException {return br.ready();}
	}
}

import java.awt.GradientPaint;
import java.awt.geom.Line2D;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;

public class a {
	public static class node {
		long one;
		long two;

		node(long index, long val) {
			one = index;
			two = val;

		}

	}

	public static int dp[] = new int[1500005];
	public static boolean sieve[] = new boolean[1500005];

	public static void ss() {
		dp[0] = dp[1] = 0;
		for (int i = 2; i < 1500005; i++) {
			if (!sieve[i]) {
				dp[i] = dp[i - 1] + 1;
				for (long j = (long) i * (long) i; j < 1500005; j += i) {
					sieve[(int) j] = true;
				}
			} else {
				dp[i] = dp[i - 1];
			}
		}
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder q = new StringBuilder();
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

		ss();

		String y[] = in.readLine().split(" ");
		int a = Integer.parseInt(y[0]);
		int b = Integer.parseInt(y[1]);
		int k = Integer.parseInt(y[2]);
		int l = k;

		if (b - l + 1 < a) {
			System.out.println(-1);
			return;
		}
		for (int i = a; i <= b - l + 1; i++) {

			int need = dp[i - 1] + k;
			int bin = Arrays.binarySearch(dp, need);

			for (int j = bin - 1; j >= 0; j--) {
				if (dp[j] == dp[j + 1])
					bin--;
				else
					break;
			}

			int r = bin - i + 1;

			if (r > l)
				l = r;
			if (b - l + 1 < a) {
				System.out.println(-1);
				return;
			}

		}
		System.out.println(l);

		out.close();

	}
}

import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a=in.nextInt(),b=in.nextInt(),k=in.nextInt();
        boolean p[]= IntegerUtils.sieve(b+1);
        int c=0,i;
        ArrayList<Integer> x=new ArrayList<Integer>();
        for(i=a;i<=b;i++)
        {
            if(p[i])
            {
                c++;
                x.add(i);
            }
        }
        if(c<k)
        {
            out.println(-1);
            return;
        }
        int min=x.get(k-1)-a+1;
        int start=0,end=k-1;
        for(i=a;i<=b;i++)
        {

            if(start==x.size()-k)
                            {
                                min=Math.max(min,b-i+1);
                                break;
                            }
            if(i>x.get(start))
            {
                start++;
                if(start==x.size()-k)
                {
                    min=Math.max(min,b-i+1);
                    break;
                }
                end++;
                min=Math.max(x.get(end)-i+1,min);
            }
            DebugUtils.print(i+" "+min);
        }
        out.println(min);
	}
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}

class IntegerUtils {
    public static boolean [] sieve(int n)
    {
        boolean prime[]=new boolean[n+1];
        Arrays.fill(prime,true);
        prime[0]=false;
        prime[1]=false;
        int sqrt=(int)Math.sqrt(n);
        for(int i=2;i<=sqrt;i++)
            if(prime[i])
                for(int k=i*i;k<=n;k+=i)
                    prime[k]=false;
        return prime;
    }

    }

class DebugUtils {
    public static void print(Object... a)
    {
        boolean oj=System.getProperty("ONLINE_JUDGE")!=null;
        if(!oj)
            System.out.println(Arrays.deepToString(a));
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * 111118315581
 *
 * -3 3 2 3 2 3 2 3 -3 3 -3 3 -3 3 2 3
 *
 * @author pttrung
 */
public class C {

    public static long x, y, gcd;
    public static int Mod = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();
        boolean[] p = new boolean[b + 1];
        p[0] = true;
        p[1] = true;
        for (int i = 2; i < p.length; i++) {
            if (!p[i]) {
                for (long j = i * i; j < p.length; j += i) {
                    if((int)j <= 0){
                       // System.out.println(j);
                        break;
                    }
                    p[(int) j] = true;
                }
            }
        }
        int[] dp = new int[b + 1];
        for (int i = 1; i < dp.length; i++) {
            dp[i] = dp[i - 1];
            if (!p[i]) {
                dp[i]++;
            }
        }
        int[] next = new int[b + 1];
        next[b] = -1;
        for (int i = b - 1; i >= a; i--) {
            if (!p[i + 1]) {
                next[i] = i + 1;
            } else {
                next[i] = next[i + 1];
            }
        }
        if (dp[b] - dp[a - 1] < k) {
            out.println(-1);
        } else {
            int result = 0;

            int start = !p[a]?a + 1: next[a]+ 1 ;
            int end = a;
            int last = a;
            for(int i = a ; i <= b; i++){
                if(dp[i] - dp[a - 1] >= k){
                    end = i;
                    result = Math.max(end - a + 1,result);
                    break;
                }
            }

          //   System.out.println(start + " " + end);
            while(end <= b && start > 0){
                end = next[end];
                if(end == -1){
                    result = Math.max(result, b - last + 1);
                    break;
                }
                result = Math.max(result, end - start + 1);
            //    System.out.println(start + " " + end);
                last = start;
                start = !p[start]?start + 1: next[start]+ 1 ;
            }

            out.println(result);

        }
        out.close();
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }
    }

    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static void extendEuclid(long a, long b) {
        if (b == 0) {
            x = 1;
            y = 0;
            gcd = a;
            return;
        }
        extendEuclid(b, a % b);
        long x1 = y;
        long y1 = x - (a / b) * y;
        x = x1;
        y = y1;

    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //      br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("basketball_game.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * 111118315581
 *
 * -3 3 2 3 2 3 2 3 -3 3 -3 3 -3 3 2 3
 *
 * @author pttrung
 */
public class C {

    public static long x, y, gcd;
    public static int Mod = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();
        boolean[] p = new boolean[b + 1];
        p[0] = true;
        p[1] = true;
        for (int i = 2; (long) i + i < p.length; i++) {
            if (!p[i]) {
                for (long j = i + i; j < p.length; j += (long) i) {
                    p[(int) j] = true;
                }
            }
        }
        int[] dp = new int[b + 1];
        for (int i = 1; i < dp.length; i++) {
            dp[i] = dp[i - 1];
            if (!p[i]) {
                dp[i]++;
            }
        }
        //System.out.println(dp[b]);
        int[] next = new int[b + 1];
        next[b] = -1;
        for (int i = b - 1; i >= a; i--) {
            if (!p[i + 1]) {
                next[i] = i + 1;
            } else {
                next[i] = next[i + 1];
            }
        }

        if (dp[b] - dp[a - 1] < k) {
            //  System.out.println("HE HE");
            out.println(-1);
        } else {
            int result = 0;
            a = !p[a] ? a : next[a];
            int start = !p[a] ? a + 1 : next[a] + 1;
            int end = a;
            int last = a;
            for (int i = a; i <= b; i++) {
                if (dp[i] - dp[a - 1] >= k) {
                    end = i;
                    result = Math.max(end - a + 1, result);
                    break;
                }
            }

            //  System.out.println(start + " " + end + " " + next[end]);
            while (end <= b && start > 0) {
                end = next[end];
                if (end == -1) {
                    result = Math.max(result, b - last + 1);
                    break;
                }
                result = Math.max(result, end - start + 1);
                //    System.out.println(start + " " + end);
                last = start;
                start = !p[start] ? start + 1 : next[start] + 1;
            }

            out.println(result);

        }
        out.close();
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }
    }

    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static void extendEuclid(long a, long b) {
        if (b == 0) {
            x = 1;
            y = 0;
            gcd = a;
            return;
        }
        extendEuclid(b, a % b);
        long x1 = y;
        long y1 = x - (a / b) * y;
        x = x1;
        y = y1;

    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //      br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("basketball_game.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.*;

public class CF237C{
  public static void main(String args[]) throws IOException {
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String line = stdin.readLine();
    String[] prms = line.split(" ");
    int a = Integer.parseInt(prms[0]);
    int b = Integer.parseInt(prms[1]);
    int k = Integer.parseInt(prms[2]);

    char[] p = new char[b+1];

    int n = p.length-1;
    p[1]=1;
    for(int i=2; i*i<=n; i++){
      if(p[i] == 0){
        for(int j=i+i; j<=n; j+=i) p[j]=1;
      }
    }
    int cnt = 0;
    int mp = 0;
    for(int i=a; i<=n; i++){
      if(p[i]==0){
        cnt++;
        mp = Math.max(mp, i);
      }
    }
    if(cnt < k) {
      System.out.println(-1);
      return;
    }

    int[] l = new int[cnt];

    int c = 1;
    int d = 0;
    for(int i=a; i<=b; i++){
      if(p[i]==0){
        l[d++]=c;
        c = 1;
      }else{
        c++;
      }
    }

    int len = 0;
    for(int j=0; j<k; j++) len+=l[j];
    int max = len;
    for(int i=1; i<cnt-k; i++){
      len = len - l[i-1] + l[i+k-1];
      max = Math.max(max, len);
    }
    if(len == max) max += (b - mp);
    System.out.println(max);
  }
}

import java.io.*;
import java.util.*;
public class Main{
    static int atoi(String n){return Integer.parseInt(n);}
    static int a,b,k;
    static int cp[];
    static boolean[] criba(int n){
        int fin = (int)Math.sqrt(n)+1;
        boolean p[] = new boolean[n+1];
        p[0] = p[1] = true;
        for(int i=0;i<fin;i++)
            if(!p[i])
                for(int j=i*i;j<p.length;j+=i)
                    p[j] = true;
        return p;
    }
    static boolean puede(int l){
        if(l<k || b-l==0)return false;
        for(int i=0,j=0;i<b-l;i++,j++){
            int suma = cp[a+j+l-1] - cp[a+j-1];
            //System.out.println(j+" "+suma+" ");
            //System.out.println();
            if(suma<k)return false;
        }
        //System.out.println("retorna true");
        return true;
    }
    static int bs(int cp[]){
        int low = 1, high = b-a+1;
        int last = -1;
        while(low<=high){
            int l = (low+high)>>1;
            //System.out.println("fijo con "+l);
            if(puede(l)){
                high = l-1;
                last = l;
            }
            else
                low = l+1;
        }
        return last;
    }
    public static void main(String jfkd[])throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String div[] = br.readLine().split(" ");
        a = atoi(div[0]);b=atoi(div[1]); k=atoi(div[2]);
        boolean p[] = criba(2*b+1);
        //for(int i=0;i<p.length;i++)
        //  if(!p[i])
        //      System.out.print(i+" ");
        //System.out.println();
        cp = new int[p.length];
        cp[0] = 0;
        for(int i=1;i<cp.length;i++)
            cp[i] += cp[i-1]+(!p[i]?1:0);
        System.out.println(bs(cp));
    }
}

import java.util.Scanner;
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.*;

public class C147 {
	static Scanner in = new Scanner(System.in);
	static PrintWriter w = new PrintWriter(System.out, true);

	static int ni() {
		return in.nextInt();
	}

	static String nl() {
		return in.nextLine();
	}

	static void pl(int v) {
		w.println(v);
	}

	static void pl(String s) {
		w.println(s);
	}

	public static void main(String[] args) {
		int a = ni(), b = ni(), k = ni();
		boolean[] e = new boolean[1000001];
		int el = e.length;
		int[] primes = new int[80000];
		int pi = 0;
		for (int i = 2; i < el; i++) {
			if (!e[i]) {
				primes[pi++] = i;
				for (int j = i + i; j < el; j += i)
					e[j] = true;
			}
		}
		int l = Arrays.binarySearch(primes, a);
		if (l < 0) l = -l -1;
		int h = Arrays.binarySearch(primes, b);
		if (h < 0) h = -h -1;
		if (h - l < k) {
			pl(-1);
		} else {
			int r = b - primes[h-k] + 1;
			r = Math.max(r, primes[l + k - 1] - a + 1);
			for (int i = l; i < h - k; i++)
				r = Math.max(r, primes[i + k] - primes[i]);
			pl(r);
		}
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class P237C {

  final int pSize = 1000001;
  boolean [] nPrime = new boolean [pSize];
  int [] cPrimes = new int [pSize];

  void genPrimes() {
    nPrime[0] = true;
    nPrime[1] = true;

    int n = (int)Math.sqrt(pSize);
    for (int i = 2; i <= n; i++) {
      if (!nPrime[i]) {
        for (int j = i * i; j < pSize; j += i) {
          nPrime[j] = true;
        }
      }
    }

    int count = 0;
    for (int i = 1; i < pSize; i++) {
      if (!nPrime[i]) {
        count++;
      }
      cPrimes[i] = count;
    }
  }

  public void run() throws Exception {
    int a = nextInt();
    int b = nextInt();
    int k = nextInt();
    genPrimes();

/*
    int tol = b - a + 1;
l:  for (int l = 1; l <= tol; l++) {
      int tox = b - l + 1;
      for (int x = a; x <= tox; x++) {
        int kk = cPrimes[x + l - 1] - cPrimes[x - 1];
        if (kk < k) { continue l; }
      }
      println(l);
      return;
    }
*/

    int tl = b - a + 1;
    int fl = 1;
    int ll = -1;
    int kk = -1;
    int l = 1;
l:  while (Math.abs(l - ll) > 0) {
      ll = l;
      l = (tl + fl + 1) / 2;
      int tox = b - l + 1;
      for (int x = a; x <= tox; x++) {
        kk = cPrimes[x + l - 1] - cPrimes[x - 1];
//System.out.println("l = " + l + "\tx = " + x + "\tkk = " + kk);
        if (kk < k) {
          fl = l;
          continue l;
        }
      }
      tl = l + 1;
    }

    if (kk >= k) {
      println(l);
    } else {
      println(-1);
    }
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P237C().run();
    br.close();
    pw.close();
  }

  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) {
        return null;
      }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) {
    print("" + b);
  }

  void print(int i) {
    print("" + i);
  }

  void print(long l) {
    print("" + l);
  }

  void print(double d) {
    print("" + d);
  }

  void print(char c) {
    print("" + c);
  }

  void print(StringBuffer sb) {
    print("" + sb);
  }

  void print(String s) {
    pw.print(s);
  }

  void println(byte b) {
    println("" + b);
  }

  void println(int i) {
    println("" + i);
  }

  void println(long l) {
    println("" + l);
  }

  void println(double d) {
    println("" + d);
  }

  void println(char c) {
    println("" + c);
  }

  void println(StringBuffer sb) {
    println("" + sb);
  }

  void println(String s) {
    pw.println(s);
  }

  int nextInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  long nextLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  double nextDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  char nextChar() throws IOException {
    return (char) (br.read());
  }

  String next() throws IOException {
    return br.readLine();
  }

}

import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    int a = in.ri(), b = in.ri(), k = in.ri();
	    int[] primes = IntegerUtils.generatePrimes(1_000_005);
	    boolean[] p = new boolean[1_000_009];
	    for(int prime : primes) p[prime] = true;
	    int min = 0, max = b - a + 1;
	    while(min < max){
		    int middle = (min + max) / 2;
		    if(works(middle, a, b, k, p, out)) max = middle;
		    else min = middle + 1;
	    }
	    out.printLine(min > (b - a + 1) ? -1 : min);
    }
	private boolean works(int val, int a, int b, int k, boolean[] p, OutputWriter out){
		int primes = 0;
		for(int i = a; i < a + val; i++) primes += p[i] == true ? 1 : 0;
if (primes < k) return false;
for(int i = a + val; i <= b; i++) {
			if(i >= p.length) break;
			primes += p[i] == true ? 1 : 0;
			primes -= p[i - val] == true ? 1 : 0;
			if(primes < k) return false;
		}
		return true;
	}
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	public int ri(){
		return readInt();
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void close() {
		writer.close();
	}
	public void printLine(int i) {
		writer.println(i);
	}

}

class IntegerUtils {
	public static int[] generatePrimes(int upTo) {
		int[] isPrime = generateBitPrimalityTable(upTo);
		IntList primes = new IntArrayList();
		for (int i = 0; i < upTo; i++) {
			if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1)
				primes.add(i);
		}
		return primes.toArray();
	}
	public static int[] generateBitPrimalityTable(int upTo) {
		int[] isPrime = new int[(upTo + 31) >> 5];
		if (upTo < 2)
			return isPrime;
		Arrays.fill(isPrime, -1);
		isPrime[0] &= -4;
		for (int i = 2; i * i < upTo; i++) {
			if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1) {
				for (int j = i * i; j < upTo; j += i)
					isPrime[j >> 5] &= -1 - (1 << (j & 31));
			}
		}
		return isPrime;
	}
}

abstract class IntCollection {
	public abstract IntIterator iterator();
	public abstract int size();
	public abstract void add(int value);
	public int[] toArray() {
		int size = size();
		int[] array = new int[size];
		int i = 0;
		for (IntIterator iterator = iterator(); iterator.isValid(); iterator.advance())
			array[i++] = iterator.value();
		return array;
	}
}

interface IntIterator {
	public int value() throws NoSuchElementException;
	public void advance() throws NoSuchElementException;
	public boolean isValid();
}

abstract class IntList extends IntCollection implements Comparable<IntList> {
	public abstract int get(int index);
	public IntIterator iterator() {
		return new IntIterator() {
			private int size = size();
			private int index = 0;

			public int value() throws NoSuchElementException {
				if (!isValid())
					throw new NoSuchElementException();
				return get(index);
			}

			public void advance() throws NoSuchElementException {
				if (!isValid())
					throw new NoSuchElementException();
				index++;
			}

			public boolean isValid() {
				return index < size;
			}
		};
	}
	public int hashCode() {
		int hashCode = 1;
		for (IntIterator i = iterator(); i.isValid(); i.advance())
			hashCode = 31 * hashCode + i.value();
		return hashCode;
	}

	public boolean equals(Object obj) {
		if (!(obj instanceof IntList))
			return false;
		IntList list = (IntList)obj;
		if (list.size() != size())
			return false;
		IntIterator i = iterator();
		IntIterator j = list.iterator();
		while (i.isValid()) {
			if (i.value() != j.value())
				return false;
			i.advance();
			j.advance();
		}
		return true;
	}

	public int compareTo(IntList o) {
		IntIterator i = iterator();
		IntIterator j = o.iterator();
		while (true) {
			if (i.isValid()) {
				if (j.isValid()) {
					if (i.value() != j.value()) {
						if (i.value() < j.value())
							return -1;
						else
							return 1;
					}
				} else
					return 1;
			} else {
				if (j.isValid())
					return -1;
				else
					return 0;
			}
			i.advance();
			j.advance();
		}
	}
}

class IntArrayList extends IntList {
	private int[] array;
	private int size;

	public IntArrayList() {
		this(10);
	}

	public IntArrayList(int capacity) {
		array = new int[capacity];
	}
	public int get(int index) {
		if (index >= size)
			throw new IndexOutOfBoundsException();
		return array[index];
	}
	public int size() {
		return size;
	}

	public void add(int value) {
		ensureCapacity(size + 1);
		array[size++] = value;
	}

	public void ensureCapacity(int newCapacity) {
		if (newCapacity > array.length) {
			int[] newArray = new int[Math.max(newCapacity, array.length << 1)];
			System.arraycopy(array, 0, newArray, 0, size);
			array = newArray;
		}
	}

	public int[] toArray() {
		int[] array = new int[size];
		System.arraycopy(this.array, 0, array, 0, size);
		return array;
	}
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	private final boolean isFileIO = false;

	final int size = 2000010;
	private int primes[] = new int[size];

	private void solve() throws IOException {
		int a = nextInt();
		int b = nextInt();
		int k = nextInt();

		Arrays.fill(primes, -1);
		primes[0] = 0;
		primes[1] = 0;

		for (int i = 2; i < size; ++i)
			if (primes[i] == -1) {
				primes[i] = 1;
				for (int j = i*2; j < size; j += i)
					primes[j] = 0;
			}

		Fenvik f = new Fenvik(primes);

		int maxl = b - a + 1;
		int left = a;
		int right = b;
		int ind = (left + right) / 2;
		int oldind = ind;
		while (!(f.get(a, ind) == k && (ind == a || f.get(a, ind - 1) < k))) {
			if (f.get(a, ind) >= k) {
				right = ind;
				oldind = ind;
				ind = (left + right) / 2;
			} else if (f.get(a, ind) < k) {
				left = ind;
				oldind = ind;
				ind = (left + right) / 2 + 1;
				if (ind > b) ind = b;
			}
			if (oldind == ind) {
				pw.print("-1");
				return;
			}
		}

		int l = ind - a + 1;

		for (int i = a; i <= b - l + 1; ++i) {
			if (f.get(i, i + l - 1) >= k)
				continue;

			for (int j = i + l; j < size; ++j) {
				++l;
				if (primes[j] == 1)
					break;
			}
		}

		pw.print(l);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	private static class Fenvik {
        private int B[];

        private Fenvik(int arr[]) {
            B = new int[arr.length];

            for (int i = 0; i < arr.length; ++i)
                update(i, arr[i]);
        }

        private void update(int i, int d) {
            for (; i < B.length; i=i|(i+1))B[i] += d;
        }

        private int get0r(int r) {
            int res = 0;
            for (; r >= 0; r=(r&(r+1))-1)res += B[r];
            return res;
        }

        private int get(int l , int r) {
        	return get0r(r) - get0r(l - 1);
        }
    }

	public void run() {
		try {
			if (isFileIO) {
				pw = new PrintWriter(new FileWriter("output.txt"));
				br = new BufferedReader(new FileReader("input.txt"));
			} else {
				pw = new PrintWriter(System.out);
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			solve();
			pw.close();
			br.close();
		} catch (IOException e) {
			System.err.println("IO Error");
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(br.readLine());
		}

		return tokenizer.nextToken();
	}

	private BufferedReader br;
	private StringTokenizer tokenizer;
	private PrintWriter pw;
}

import java.util.*;
import java.io.*;
public class Main {
    int INF = 1 << 24;
    int n;
    ArrayList<Integer> prime;
    int MAX = 1000000;

    //0201
    private void doit(){
        InStream sc = new InStream();
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a > b){
                int temp = a;
                a = b;
                b = temp;
            }
            int k = sc.nextInt();

            eratos();

            int l = -1;
            for(int i = a; i <= b; i++){
                int res = binaySearch(i);
                if(res >= prime.size()) continue;
                int res2 = binaySearch(i) + k - 1;
                if(res2 < prime.size()){
                    int ind = prime.get(res2);
                    //System.out.println("res = " + res + " v = " + prime.get(res) + " ind = " + ind);
                    if(ind <= b){
                        int value = ind - i + 1;
                        l = Math.max(l, value);
                    }

                }

                int ind2 = res - 1 - k + 1;
                if(prime.get(res) == i){
                    ind2++;
                }
                //System.out.println("res = " + res + " v = " + prime.get(res) + " ind = " + ind2 + " i = " + i);
                if(ind2 >= 0){

                    if(prime.get(ind2) >= a){
                        int v2 = i - prime.get(ind2) + 1;
                        //System.out.println("v2 = " + v2);
                        l = Math.max(l, v2);
                    }
                }
            }
            System.out.println(l);
        }
    }

    //バイナリサーチ
    private int binaySearch(int patt){
        int mid, left = 0, right = prime.size()-1;
        while(left <= right){
            mid = (left + right) / 2;
            if(prime.get(mid) == patt){
                return mid;
            }
            if(prime.get(mid) < patt){
                left = mid + 1;
            }
            else{
                right = mid - 1;
            }
        }
        return left;
    }

    private void eratos(){

        prime = new ArrayList<Integer>();
        int MAX = 1000000;
        boolean [] isprime = new boolean[MAX + 1];
        Arrays.fill(isprime, true);
        isprime[0] = false;
        isprime[1] = false;
        for(int i = 2; i <= MAX; i++){
            if(isprime[i]){
                prime.add(i);
                for(int j = i * 2; j <= MAX; j+= i){
                    isprime[j] = false;
                }
            }
        }
    }

    private void doitB(){
        InStream sc = new InStream();
        while(sc.hasNext()){
            n = sc.nextInt();
            int [] ci = new int[n];
            int maxci = 0;
            for(int i = 0 ; i < n; i++){
                ci[i] = sc.nextInt();
                maxci = Math.max(maxci, ci[i]);
            }

            int [][] data = new int[n][maxci];
            for(int i = 0 ; i< n; i++){
                Arrays.fill(data[i], INF);
            }
            for(int i = 0 ;i < n; i++){
                for(int j = 0; j < ci[i]; j++){
                    data[i][j] = sc.nextInt();
                }
            }

            int count = 0;
            ArrayList<String> ans = new ArrayList<String>();
            for(int i = 0 ; i < n; i++){
                for(int j = 0; j < maxci; j++){
                    if(data[i][j] == INF) continue;
                    int x = i, y = j;
                    int [] res = find(data, x, y);
                    if(res[0] == x && res[1] == y){
                        continue;
                    }
                    data = swap(data, x,y, res[0], res[1]);
                    ans.add((x+1) + " " + (y+1) + " " + (res[0]+1) + " " + (res[1] + 1));
                    count++;
                }
            }
            System.out.println(count);
            for(int i = 0 ; i< ans.size(); i++){
                System.out.println(ans.get(i));
            }
        }
    }

    private int[][] swap(int[][] data, int x, int y, int i, int j) {
        int temp = data[x][y];
        data[x][y] = data[i][j];
        data[i][j] = temp;
        return data;
    }

    private int [] find(int[][] data, int x, int y) {
        int min = INF;
        int indx = -1;
        int indy = -1;
        for(int i = x; i <data.length ; i++){
            for(int j = y; j < data[i].length; j++){
                if(min > data[i][j]){
                    min = data[i][j];
                    indx = i;
                    indy = j;
                }
            }
        }
        return new int[]{indx, indy};
    }

    private void doitA(){
        InStream sc = new InStream();
        while(sc.hasNext()){
            int n = sc.nextInt();
            int nowh = sc.nextInt();
            int nowm = sc.nextInt();
            int count = 1;
            int ans = 1;
            for(int i = 1; i < n; i++){
                int h = sc.nextInt();
                int m = sc.nextInt();
                if(nowh == h && nowm == m){
                    count++;
                    ans = Math.max(count, ans);
                }
                else{
                    count = 1;
                    nowh = h;
                    nowm = m;
                }

            }
            System.out.println(ans);
        }
    }

    class InStream{
        BufferedReader in;StringTokenizer st;
        public InStream() {
            this.in = new BufferedReader(new InputStreamReader(System.in));
            this.st = null;
        }
        String next() {
            while (st==null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (Exception e) {}
            }
            return st.nextToken();
        }
        boolean hasNext(){
            try {
                st = new StringTokenizer(in.readLine());
                return true;
            } catch (Exception e) {return false;}
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() {return Long.parseLong(next()); }
        double nextDouble() {return Double.parseDouble(next()); }
    }

    public static void main(String[] args) {
        Main obj = new Main();
        obj.doit();
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public static void main(String args[]) {

		Scanner scn = new Scanner(System.in);

		int a = scn.nextInt();
		int b = scn.nextInt();

		int k = scn.nextInt();

		ArrayList<Integer> list = SOE(b, a);
		int n = list.size();

		if (n < k) {
			System.out.println(-1);
			return;
		}

		if (n == k) {
			System.out.println(b - a + 1 - Math.min(list.get(0) - a, b - list.get(n - 1)));
			return;
		}
		int ans = list.get(k - 1) - a;

		for (int i = k; i < n; i++) {

			if (list.get(i) - list.get(i - k) > ans) {
				ans = list.get(i) - list.get(i - k);
			}

		}

		if (b - list.get(n - k) > ans) {
			ans = b - list.get(n - k - 1);
		}
		System.out.println(ans);

	}

	public static ArrayList<Integer> SOE(int n, int a) {

		boolean arr[] = new boolean[n + 1];

		Arrays.fill(arr, true);

		for (int table = 2; table * table <= n; table++) {

			if (arr[table] == true) {

				for (int mult = 2; mult * table <= n; mult++) {
					arr[table * mult] = false;
				}
			}
		}

		arr[0] = arr[1] = false;

		ArrayList<Integer> list = new ArrayList<>();

		for (int i = a; i < n + 1; i++) {

			if (arr[i])
				list.add(i);
		}

		return list;

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A{
	static InputReader in = new InputReader(System.in);
	static int arr[];
	static int b,a,k;
	static boolean isPrime[] = new boolean[(int)10e6+2];
	static int N = (int)10e6+1;

	static void sieve(){
		Arrays.fill(isPrime,true);
		isPrime[0] = false;
		isPrime[1] = false;
		for(int i=2;i*i<=N;i++){
			if(isPrime[i]){
				for(int j=i*2;j<=N;j+=i){
					isPrime[j] = false;
				}
			}
		}
	}

	static boolean P(int l){
		int cnt = 0;
		for(int i=0;i<l-1;i++){
			if(isPrime[a+i])cnt++;
		}
		if(cnt>=k) return true;
		else return false;

	}
	public static void main(String[]args)throws Throwable{
		a = in.j(); b = in.j(); k =in.j(); sieve();
		int lo = 1;
		int hi = b-a+1;
		int r = -1;
		while(lo<=hi){
			int mid = lo+(hi-lo)/2;
			if(P(mid)){
				hi = lo-1;
				r = mid;
			}
			else lo = mid+1;
		}
		System.out.println(r);
	}

	static	class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int j() {
			return Integer.parseInt(next());
		}
		public long readLong(){
			return Long.parseLong(next());
		}

	}
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static int a,b,k;
	static boolean[] isPrime;
	static void sieve()
	{
		isPrime = new boolean[100+(((int)1e6)<<1)];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; i++)
			if(isPrime[i])
				for(int j = i<<1 ; j<isPrime.length;j+=i)
					isPrime[j] = false;
	}
	static int solve()
	{
		int len = 0 , bound = b-a+1;
		int l = a,r=a, count = 0;
		while(l<=b-len+1)
		{
			if(r<=l)
			{
				r=l;
				count=0;
			}
			int curR = r;
			while(count<k && r-l<bound)
				if(isPrime[r++])count++;
			if(count!=k)
			{
				while(r>curR)
					if(isPrime[r--])count--;
				l--;
				if(isPrime[l])count++;
				while(r-l<=bound && l<b-(r-l)+1)
				{
					if(isPrime[r++])count++;
				}
				len = Math.max(len, r-l);
				break;
			}
			if(isPrime[l])
				count--;

			len = Math.max(len, r-l++);
		}
		return (len>bound)?-1:len;
	}
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner((System.in));
		a = sc.nextInt();
		b = sc.nextInt();
		k = sc.nextInt();
		sieve();
		System.out.println(solve());
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(s));
		}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public boolean ready() throws IOException {return br.ready();}
	}
}

import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{

	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
	//  Stack<Integer> que = new Stack<Integer>();
    //	static long sum=0;
	// int a,b,c;
	// 1000000007 (10^9+7)
	static int mod = 1000000007;
    //static int dx[]={1,-1,0,0};
	//static int dy[]={0,0,1,-1};
    //static long H,L;

public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	// !!caution!! int long //
	Reader sc = new Reader(System.in);
  // while( ){
	  // int  n=sc.nextInt(),m=sc.nextInt();//a[]=new int[n],b[]=new int[n];
	int  a=sc.nextInt(), b=sc.nextInt(),k=sc.nextInt();
	int  p[]=new int[b+1];
	boolean x[]=new boolean[1000001];
	for(int t=2	;t<=sqrt(1000000) ;t++){
		if(!x[t]){
			for(int i=t	;t*i<=1000000 ;i++){
				x[i*t]=true;
			}
		}
	}
	x[1]=true;
	for(int t=1	;t<=b ;t++){
		if(!x[t]){ p[t]=p[t-1]+1; }
		else p[t]=p[t-1];
	}
	//db(p[b],p[a-1]);
//	db(p);
	if( p[b]-p[a-1]<k ){ System.out.println(-1); return; }

	int l=b-a+1;
	int hi=l,dw=1,mid=(hi+dw)/2;
	for(int t=0	;t<=50 ;t++){
		boolean f=true;
		for(int i=a; i+mid-1<=b ;i++){
		//	db(mid,p[i+mid-1]-p[i-1]);
			if( p[i+mid-1]-p[i-1]<k ){ f=false; break; }

		}

		if( f ){ l=min(l,mid); ; dw=mid;mid=(hi+dw)/2;}
		else { hi=mid; mid=(hi+dw)/2;}
	}

   System.out.println(l);
}

/*
class P implements Comparable<P>{
//	implements Comparable<P>

	int x;
	long  d;
	P(int x,long b){
		this.x=x;
		d=b;
	}

	   public int compareTo(P y){

		  return  0<=(d-y.d) ? 1:-1;

		   }

}*/

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}

}

//*/
class Reader
{
	private BufferedReader x;
	private StringTokenizer st;

	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}

import java.util.*;
import java.io.*;

public class Problems {

    private static boolean primes[];

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        /*
        6 13 1
         */
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();

        primes = new boolean[b + 1];
        countPrimes(primes);

        int interval = 0;
        int tempK = 0;
        int end = a;
        int start = a;
        boolean f = false;

        for (int i = a; i <= b; ++i) {
            start = i;

            for (; end <= b; ++end) {
                if (tempK == k) {
                    ++end ;
                    break;
                }
                if (primes[end]) {
                    ++tempK;
                    if (tempK == k) {
                        interval = Math.max(interval, end + 1 - start);
                        ++end ;
                        break;
                    }
                }
                if (end == b) {
                    f = true;
                    break;
                }
            }
            if (f) {
                break;
            }

            if (primes[start]) {
                tempK--;
            }

        }

        if (interval == 0) {
            out.println(-1);
        } else {
            if (f) {
                out.println(end + 2 - start);
            } else {
                out.println(interval);
            }
        }

        out.close();

    }

    public static void countPrimes(boolean primes[]) {
        for (int i = 2; i <= primes.length - 1; ++i) {
            boolean s = true;
            for (int x = 2; x * x <= i; ++x) {
                if (i % x == 0) {
                    s = false;
                    break;
                }
            }
            if (s) {
                primes[i] = true;
            }
        }
    }

}

class InputReader {

    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C147 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int mx = 2000002;
        boolean[] prime = new boolean[mx];
        List<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i < mx; i++) {
            if(prime[i]) continue;
            else primes.add(i);
            for(long j = (long)i * i; j < mx; j += i) {
                prime[(int)j] = true;
            }
        }
        String[] ss = br.readLine().split(" ");
        int a = Integer.parseInt(ss[0]);
        int b = Integer.parseInt(ss[1]);
        int k = Integer.parseInt(ss[2]);
        int mxg = 1;
        for(int i = 0; i < primes.size() - k; i++) {
            if(primes.get(i) < a) continue;
            if(primes.get(i + k) > b) break;
            int g = primes.get(i + k) - primes.get(i);
            if(g > mxg) {
                mxg = g;
            }
        }
        System.out.println(mxg);
    }
}

import java.io.*;
import java.util.*;

public class Main
{
	BufferedReader in;
	PrintStream out;
	StringTokenizer tok;
	public Main() throws NumberFormatException, IOException
	{
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new FileReader("in.txt"));
		out = System.out;
		run();
        }

	void run() throws NumberFormatException, IOException
	{
          Criba(1000001);
          //out.println(count);
          int a = nextInt();
          int b = nextInt();
          int k = nextInt();
          int i = 0;
          int resp = -1;
          while(i < count && Primos[i] < a)i++;
          int first = -1;
          if(i + k - 1 < count && Primos[i + k -1] <= b)first = Primos[i + k - 1] - a + 1;
          if(first == -1)
          {
              out.println(-1);
              return;
          }
          int before = i;
          i = count-1;
          int last = -1;
          while(i >= 0 && Primos[i] > b)i--;
          if(i - k + 1 >= 0 && Primos[(i - k + 1)] >= a)last = b - Primos[i - k + 1] + 1;

          for(int j = before + k - 1; j < count && Primos[j] <= b; j++)
          {
              if(j - k < 0)resp = Math.max(resp, Primos[j]);
              else resp = Math.max(resp, Primos[j] - Primos[j - k]);
          }
          out.println(Math.max(resp, Math.max(last, first)));
	}
 int[] Primos;
 int count = 0;
 boolean[] mask;

 void Criba(int n)
    {
	mask = new boolean[n+1];
	int raiz = (int)Math.sqrt(n);
Primos = new int[n/2+1];
	for (int i= 2; i <= 3; i++)
	for (int j = i*i; j <= n; j+=i)
		mask[j] = true;
	for(int i = 6; i<=raiz; i+=6)
      {
		i--;
		if(!mask[i])
		for (int j = i*i; j <= n; j	+= i)
			mask[j] = true;
		i += 2;
		if(!mask[i])
			for (int j = i*i; j <= n; j	+= i)
				mask[j] = true;
		i--;
      }
	Primos[0] = 2; Primos[1] = 3; count = 2;
	for(int i = 6; i <= n; i+=6)
	{
		if(!mask[i-1])Primos[count++] = i-1;
		if(!mask[i+1])Primos[count++] = i+1;
	}
    }

	public static void main(String[] args) throws NumberFormatException, IOException
	{
		new Main();
	}
        String nextToken() throws IOException
	{
		String line = "";
		while(tok == null || !tok.hasMoreTokens()) {
			if((line = in.readLine()) != null)
				tok = new StringTokenizer(line);
			else
				return null;
		}
		return tok.nextToken();
	}
	int nextInt() throws NumberFormatException, IOException
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws NumberFormatException, IOException
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws NumberFormatException, IOException
	{
		return Double.parseDouble(nextToken());
	}

}

import java.util.*;
public  class Solution{
	//sieve
	public static boolean[] sieve(){
		int MAX=1000002;

		boolean[] prime=new boolean[MAX+1];
		for(int i=0;i<=MAX;i++)
			prime[i]=true;
		prime[0]=false;
		prime[1]=false;
		for(int i=2;i*i<=MAX;i++)
		{
			if(prime[i]==true)
				{for(int j=i*i;j<=MAX;j+=i)
					prime[j]=false;}
		}
		return prime;
	}

	//main
	public static void main(String[] args){
		int MAX=1000002;
    Scanner in=new Scanner(System.in);
     int a=in.nextInt();
     int b=in.nextInt();
     int k=in.nextInt();
     int i=0,count=0,l=0;
     boolean[] prime=new boolean[MAX+1];
     prime=sieve();
	 int max=0;
     for (int p = a;p <=  b; p++)
    	 if(prime[p])count++;
     if(count<k)
    	 System.out.println("-1");
     else{
    	 int m=0;
    	 int[] pr=new int[count];
    	 for(int p=a; p<=b; p++){
    		 if(prime[p])
    	  pr[m++]=p;
    	 }
    	 max=Math.max(pr[k-1]-a,b-pr[count-k]+1);
    	 for(i=k;i<count;i++){
    	  max=Math.max(max,pr[i]-pr[i-k]);
    	 }
    	 System.out.println(max);
     }

}}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
    public class Main
    {
        public static void main(String[] args)
        {
        Scanner sc =new Scanner(System.in);
        int i=0;
        int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
        int l=0;
        int[] mas = new int[b-a+3];
        i=1;mas[0]=a-1;
        for(int j=a;j<=b;j++)
        {
            if(prost(j)){mas[i]=j;i++;}
        }

        mas[i]=b+1;
        int maxx=0;

        for(int lal=0;lal<=i+1;lal++){}
        for(int max=c;max<=i;max++)
        {

            maxx=Math.max(maxx, mas[max]-mas[max-c]);
        }
        if(maxx==0)maxx=-1;
        System.out.println(maxx);
    }
        public static boolean prost(int lol)
        {
            boolean lal=true;

            for(int i=2;i<=Math.sqrt(lol);i++)
            {
                if(lol%i==0){lal=false;break;}
            }
            if(lol==1)lal=false;
            return lal;
        }
    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C147 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int mx = 2000002;
        boolean[] prime = new boolean[mx];
        List<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i < mx; i++) {
            if(prime[i]) continue;
            else primes.add(i);
            for(long j = (long)i * i; j < mx; j += i) {
                prime[(int)j] = true;
            }
        }
        prime[0] = true;
        prime[1] = true;
        int[] ctprimes = new int[mx];
        int ct = 0;
        for(int i = 0; i < mx; i++) {
            if(!prime[i]) ct++;
            ctprimes[i] = ct;
        }
        String[] ss = br.readLine().split(" ");
        int a = Integer.parseInt(ss[0]);
        int b = Integer.parseInt(ss[1]);
        int k = Integer.parseInt(ss[2]);
        int mxg = 101;
        for(int i = 0; i < primes.size() - k - 1; i++) {
            if(primes.get(i + k - 1) > b) break;
            int g = primes.get(i + k - 1) - primes.get(i);
            if(g > mxg) {
                mxg = g;
            }
        }
        for(int l = mxg - 100; l <= b - a + 1; l++) {
            boolean pass = true;
            for(int x = a; pass && x <= b - l + 1; x++) {
                if(ctprimes[x + l - 1] - ctprimes[x] + (prime[x] ? 0 : 1) < k)
                    pass = false;
            }
            if(pass) {
                System.out.println(l);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}

import java.util.*;
import java.io.*;
import java.lang.*;
public class C237 {
	private static long mod = 1000000007;

	public static void main(String[] args) {
		InputReader in=new InputReader(System.in);
		PrintWriter pw=new PrintWriter(System.out);

		int a=in.nextInt();
		int  b=in.nextInt();
		int k=in.nextInt();

		boolean p[]=new boolean[1000006];
		sieve(p, 1000006);
		for(int i=0;i<=b;i++) {
		if(p[i]==true)
			pw.print(1+" ");
		else
			pw.print(0+" ");
		}

		pw.println();
		int[] arr=new int[b+1];
		int c=0,count=0;
		int max=-2;
		int last_1=0;
	//	pw.print(p[1]);
		for(int i=a;i<=b;i++) {
			int n_1=0;
			count=0;
			int j=0;
			for(j=i;j<=b;j++) {
				if(p[j]) {
					n_1++;
					last_1=j;
				}
				if(n_1==k)
					break;
				count++;
			}
			if(j<=b)
			arr[i]=count;
			else
				arr[i]=-1;
			max=Math.max(arr[i],max);
		}
		for(int i=a;i<=b;i++)
		pw.print(arr[i]+" ");
		if(max>0)
		pw.println(max+1);
		else
			pw.println(-1);

		pw.flush();
		pw.close();
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		public long[] nextLongArray(int n) {
			long a[] = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static ArrayList<Integer> primeFactorization(int n)
	{
		ArrayList<Integer> a =new ArrayList<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {

	static public boolean primos[];
	static public int dp[];
	static int sol;

	static public void primos_cal() {
		primos = new boolean[1000001];
		Arrays.fill(primos, true);
		for (int i = 2; i < 1000001; i++) {
			if (!primos[i])
				continue;
			for (int j = 2; (j * i) < 1000001; j++) {
				primos[j * i] = false;
			}
		}
	}

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		primos_cal();
		primos[1] = false;
		dp = new int[1000001];
		for (int i = 1; i < 1000001; i++) {
			dp[i] = dp[i - 1];
			if (primos[i])
				dp[i]++;
		}

		String linea[] = br.readLine().split(" ");
		int a = Integer.parseInt(linea[0]);
		int b = Integer.parseInt(linea[1]);
		int k = Integer.parseInt(linea[2]);

		int I = b - a + 1;
		int rango_a = a - 1;
		int rango_b;
		int solucion = -1;
		boolean flag; int cal;
		sol = 999999;

			  int centro,inf=1,sup=I;

			   while(inf<=sup){
				   //inf<=sup

			     centro=(sup+inf)/2;
			     //System.out.println(centro);
			     int dato = bb(b,centro,k,a);
			     if(dato>=k) sup=centro-1;
			     else
			    	 inf=centro+1;
			   }

		if(sol == 999999){
			sol= -1;
		}
		pr.printf("%d\n", sol);
		pr.close();
	}

	static int bb(int b,int i,int k,int a){

		int rango_b = b - i + 1;
		boolean flag = true;
		int k_max = 0;
		for (int x = a; x <= rango_b; x++) {
			int cal = dp[x + i - 1] - dp[x - 1];
			if (cal < k) {
				flag = false;
			}
			Math.max(cal,k_max);
		}
		if(flag){
			if(i > sol){
				System.out.println(sol);
				System.exit(0);
			}

			sol = Math.min(sol,i);

		}
		return k_max;

	}
}

/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;

public class test {
    int INF = (int)1e9;
    long MOD = 1000000007;

    void solve(InputReader in, PrintWriter out) throws IOException {
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();
        int[] p = new int[b+1];
        p[0] = 1; p[1] = 1;
        for(int i=2; i<=b; i++) {
            if(p[i]>0) continue;
            if(1l*i*i>b) continue;
            for(int j=i*i; j<=b; j+=i) {
                p[j] = 1;
            }
        }
        // show("p", p);
        int i = a, j = a;
        int t = p[i]^1;
        int m = b-a+1;
        int l = 1;
        // show("ij", i, j, t);
        while(i<=b-l+1) {
            while(t<k) {
                j++;
                if(j>b) break;
                t += p[j]^1;
                // show("chk", i, j, t);
            }
            if(t<k) {
                t = 0;
                for(i=a; i<=b; i++) {
                    t += p[i]^1;
                }
                if(t<k) out.println(-1);
                else out.println(m);
                return;
            }
            // show("ij", i, j, t);
            l = Math.max(l, j-i+1);
            t -= p[i]^1;
            i++;
        }
        out.println(l);
    }

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        while(t-- >0) {
            new test().solve(in, out);
        }
        out.close();
    }

    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }

    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

import java.util.*;
import java.io.*;
public class Main {
    int INF = 1 << 24;
    int n;
    ArrayList<Integer> prime;
    int MAX = 1000000;

    //0201
    private void doit(){
        InStream sc = new InStream();
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int k = sc.nextInt();

            eratos();

            int l = -1;
            for(int i = a; i <= b; i++){
                int res = binaySearch(i);
                int ind = prime.get(res + k -1);
                //System.out.println("res = " + res + " v = " + prime.get(res) + " ind = " + ind);
                if(ind > b) continue;
                int value = ind - i + 1;
                l = Math.max(l, value);
            }
            System.out.println(l);
        }
    }

    //バイナリサーチ
    private int binaySearch(int patt){
        int mid, left = 0, right = prime.size()-1;
        while(left <= right){
            mid = (left + right) / 2;
            if(prime.get(mid) == patt){
                return mid;
            }
            if(prime.get(mid) < patt){
                left = mid + 1;
            }
            else{
                right = mid - 1;
            }
        }
        return left;
    }

    private void eratos(){

        prime = new ArrayList<Integer>();
        int MAX = 1000000;
        boolean [] isprime = new boolean[MAX + 1];
        Arrays.fill(isprime, true);
        isprime[0] = false;
        isprime[1] = false;
        for(int i = 2; i <= MAX; i++){
            if(isprime[i]){
                prime.add(i);
                for(int j = i * 2; j <= MAX; j+= i){
                    isprime[j] = false;
                }
            }
        }
    }

    private void doitB(){
        InStream sc = new InStream();
        while(sc.hasNext()){
            n = sc.nextInt();
            int [] ci = new int[n];
            int maxci = 0;
            for(int i = 0 ; i < n; i++){
                ci[i] = sc.nextInt();
                maxci = Math.max(maxci, ci[i]);
            }

            int [][] data = new int[n][maxci];
            for(int i = 0 ; i< n; i++){
                Arrays.fill(data[i], INF);
            }
            for(int i = 0 ;i < n; i++){
                for(int j = 0; j < ci[i]; j++){
                    data[i][j] = sc.nextInt();
                }
            }

            int count = 0;
            ArrayList<String> ans = new ArrayList<String>();
            for(int i = 0 ; i < n; i++){
                for(int j = 0; j < maxci; j++){
                    if(data[i][j] == INF) continue;
                    int x = i, y = j;
                    int [] res = find(data, x, y);
                    if(res[0] == x && res[1] == y){
                        continue;
                    }
                    data = swap(data, x,y, res[0], res[1]);
                    ans.add((x+1) + " " + (y+1) + " " + (res[0]+1) + " " + (res[1] + 1));
                    count++;
                }
            }
            System.out.println(count);
            for(int i = 0 ; i< ans.size(); i++){
                System.out.println(ans.get(i));
            }
        }
    }

    private int[][] swap(int[][] data, int x, int y, int i, int j) {
        int temp = data[x][y];
        data[x][y] = data[i][j];
        data[i][j] = temp;
        return data;
    }

    private int [] find(int[][] data, int x, int y) {
        int min = INF;
        int indx = -1;
        int indy = -1;
        for(int i = x; i <data.length ; i++){
            for(int j = y; j < data[i].length; j++){
                if(min > data[i][j]){
                    min = data[i][j];
                    indx = i;
                    indy = j;
                }
            }
        }
        return new int[]{indx, indy};
    }

    private void doitA(){
        InStream sc = new InStream();
        while(sc.hasNext()){
            int n = sc.nextInt();
            int nowh = sc.nextInt();
            int nowm = sc.nextInt();
            int count = 1;
            int ans = 1;
            for(int i = 1; i < n; i++){
                int h = sc.nextInt();
                int m = sc.nextInt();
                if(nowh == h && nowm == m){
                    count++;
                    ans = Math.max(count, ans);
                }
                else{
                    count = 1;
                    nowh = h;
                    nowm = m;
                }

            }
            System.out.println(ans);
        }
    }

    class InStream{
        BufferedReader in;StringTokenizer st;
        public InStream() {
            this.in = new BufferedReader(new InputStreamReader(System.in));
            this.st = null;
        }
        String next() {
            while (st==null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (Exception e) {}
            }
            return st.nextToken();
        }
        boolean hasNext(){
            try {
                st = new StringTokenizer(in.readLine());
                return true;
            } catch (Exception e) {return false;}
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() {return Long.parseLong(next()); }
        double nextDouble() {return Double.parseDouble(next()); }
    }

    public static void main(String[] args) {
        Main obj = new Main();
        obj.doit();
    }
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static int a,b,k;
	static boolean[] isPrime;
	static void sieve()
	{
		isPrime = new boolean[100+(((int)1e6)<<1)];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; i++)
			if(isPrime[i])
				for(int j = i<<1 ; j<isPrime.length;j+=i)
					isPrime[j] = false;
	}
	static int solve()
	{
		int len = 0 , bound = b-a+1;
		int l = a,r=a, count = 0;
		while(l<=b-len+1)
		{
			while((r<=l)||(count<k && r-l-1<=bound))
				if(isPrime[r++])count++;
			if(count!=k)
				return -1;
			if(isPrime[l])
				count--;
			len = Math.max(len, r-l++);
		}
		return (len>bound)?-1:len;
	}
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner((System.in));
		a = sc.nextInt();
		b = sc.nextInt();
		k = sc.nextInt();
		sieve();
		System.out.println(solve());
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(s));
		}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public boolean ready() throws IOException {return br.ready();}

	}

}

import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
    boolean[] sieve = new boolean[1000001];
    Arrays.fill(sieve, true);
    sieve[0]=sieve[1]=false;
    for(int i = 2; i<sieve.length; i++) if(sieve[i]) for(long j = (long)i*i; j<sieve.length; j+=i) sieve[(int)j] = false;
    //Scanner input = new Scanner(new File("input.txt"));
    //PrintWriter out = new PrintWriter(new File("output.txt"));
    PrintWriter out = new PrintWriter(System.out);
    input.init(System.in);
    int a = input.nextInt(), b = input.nextInt(), k = input.nextInt();
    int lo = 1, hi = b-a+1;
    while(hi>lo+1)
    {
        int mid = (lo+hi)/2;
        boolean valid = go(a, b, k, mid, sieve);
        if(valid)
            hi = mid;
        else
            lo = mid;
    }
    if(!go(a, b, k, lo, sieve)) lo++;
    if(!go(a, b, k, lo, sieve)) lo=-1;
    out.println(lo);
    out.close();
}
static boolean go(int a, int b, int k, int mid, boolean[] sieve)
{
    boolean valid = true;
    int x=a,count = 0;
    for(int  i= 0; i<mid; i++)
        if(sieve[a+i]) count++;
    valid &= count >= k;
    while(x+mid<=b)
    {
        if(sieve[x])count--;
        if(sieve[x+mid])count++;
        x++;
        valid &= count>=k;
    }
    //out.println(mid+" "+valid);
    return valid;
}
public static long gcd(long a, long b)
{
if(b == 0) return a;
return gcd(b, a%b);
}
public static class input {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}
static class IT
{
    int[] left,right, val, a, b;
    IT(int n)
    {
        left = new int[3*n];
        right = new int[3*n];
        val = new int[3*n];
        a = new int[3*n];
        b = new int[3*n];
        init(0,0, n);
    }
    int init(int at, int l, int r)
    {
        a[at] = l;
        b[at] = r;
        if(l==r)
            left[at] = right [at] = -1;
        else
        {
            int mid = (l+r)/2;
            left[at] = init(2*at+1,l,mid);
            right[at] = init(2*at+2,mid+1,r);
        }
        return at++;
    }
    //return the sum over [x,y]
    int get(int x, int y)
    {
        return go(x,y, 0);
    }
    int go(int x,int y, int at)
    {
        if(at==-1) return 0;
        if(x <= a[at] && y>= b[at]) return val[at];
        if(y<a[at] || x>b[at]) return 0;
        return go(x, y, left[at]) + go(x, y, right[at]);
    }
    //add v to elements x through y
    void add(int x, int y, int v)
    {
        go3(x, y, v, 0);
    }
    void go3(int x, int y, int v, int at)
    {
        if(at==-1) return;
        if(y < a[at] || x > b[at]) return;
        val[at] += (Math.min(b[at], y) - Math.max(a[at], x) + 1)*v;
        go3(x, y, v, left[at]);
        go3(x, y, v, right[at]);
    }
}
}

import java.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class Start {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    public static void main(String[] args) {
        new Start().run();
    }

    public static void mergeSort(int[] a) {
        mergeSort(a, 0, a.length - 1);
    }

    private static void mergeSort(int[] a, int levtIndex, int rightIndex) {
        final int MAGIC_VALUE = 50;
        if (levtIndex < rightIndex) {
            if (rightIndex - levtIndex <= MAGIC_VALUE) {
                insertionSort(a, levtIndex, rightIndex);
            } else {
                int middleIndex = (levtIndex + rightIndex) / 2;
                mergeSort(a, levtIndex, middleIndex);
                mergeSort(a, middleIndex + 1, rightIndex);
                merge(a, levtIndex, middleIndex, rightIndex);
            }
        }
    }

    private static void merge(int[] a, int levtIndex, int middleIndex,
            int rightIndex) {
        int length1 = middleIndex - levtIndex + 1;
        int length2 = rightIndex - middleIndex;
        int[] levtArray = new int[length1];
        int[] rightArray = new int[length2];
        System.arraycopy(a, levtIndex, levtArray, 0, length1);
        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
        for (int k = levtIndex, i = 0, j = 0; k <= rightIndex; k++) {
            if (i == length1) {
                a[k] = rightArray[j++];
            } else if (j == length2) {
                a[k] = levtArray[i++];
            } else {
                a[k] = levtArray[i] <= rightArray[j] ? levtArray[i++]
                        : rightArray[j++];
            }
        }
    }

    private static void insertionSort(int[] a, int levtIndex, int rightIndex) {
        for (int i = levtIndex + 1; i <= rightIndex; i++) {
            int current = a[i];
            int j = i - 1;
            while (j >= levtIndex && a[j] > current) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = current;
        }
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    class LOL implements Comparable<LOL> {
        int x;
        int y;

        public LOL(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(LOL o) {
           //   return x - o.x; // ---->
            // return o.x - x; // <----
            return  y - o.y;
        }

    }

    public void solve() throws IOException {

        int a = readInt();
        int b = readInt();
        int k = readInt();

        ArrayList<Integer> prime = new ArrayList<Integer>();
        int n = 2*b;
        boolean used []  = new boolean [n+1];
        Arrays.fill(used, true);
        used[0]=used[1]=false;
        for (int i =2; i<=n; i++){
            if (used[i]){
                for (int j = i*i; j<=n; j+=i)
                        if (j>0 && j<=n)
                            used[j]=false;
                        else break;
            }
        }

        for (int i =2; i<=n; i++) {
            if (used[i]) prime.add(i);
        }

        int  t = 0;

        int left = 1;
        int right = b-a+1;
        boolean yes = true;
        int l = (left+right)/2;
        boolean first = true;
    a:  while(left<=right){
        if (!first){
            if (yes){
                right = l-1;
            }
            else {
                left = l+1;
            }
             l = (left+right)/2;
        }
        else {
            first = false;
        }

        for (int x = b-l+1; x >= a; x--){
            if (used[x]){
                t++;
            }
        }
        if (t<k){
            yes  = false;
            continue a;
        }

    b:      for (int x = b-l+1; x >=a;  x--){
                t = 0;
                for (int i = x; i <= x+l-1; i++){
                    if (used[i]){
                        t++;
                        if (t>=k) {
                            yes = true;
                            continue b;
                        }
                    }
                }
                yes  = false;
                continue a;
            }
            out.print(l);
            return;
        }
        out.print(-1);
    }

}

import java.util.Scanner;

public class C_237_Primes_on_Interval {
	private static boolean isPrime(int n){
		boolean isTrue=true;
		for(int i=2;i<=Math.sqrt(n);i++){
			if(n%i==0){isTrue=false;}
		}
		return isTrue;
	}
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int a=input.nextInt(),b=input.nextInt(),k=input.nextInt();
		int i,l=0;
		for(i=a;i<=b;i++){
			if(isPrime(i)){
				l++;
				if(l==k)break;
			}
		}
		if(i>b)System.out.println(-1);
		else
			System.out.println(l);
	}
}

import java.io.*;
import java.util.*;

public class Example {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(in.readLine());
            } catch (Exception e) {
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
    static boolean[] prime = new boolean[10000001];
    static int a, b, k;

    public void run() throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        a = nextInt();
        b = nextInt();
        k = nextInt();
        Arrays.fill(prime, true);
        prime[1] = false;
        for (int i = 2; i <= b; i++) {
            if (prime[i]) {
                if (i < Math.sqrt(b)) {
                    for (int j = i * i; j <= b && j > 1; j += i) {
                        if (prime[j] = true) {
                            prime[j] = false;
                        }
                    }
                }
            }
        }
        int begin = 1;
        int end = b - a + 1;
        int l = (begin + end) / 2;

        while (true) {
            boolean ok = f(l);
            if (ok && !f(l - 1)) {
                break;
            }
            if (l == end) {
                l = -1;
                break;
            }
            if (ok) {
                end = l;
            } else {
                begin = l;
            }
            l = (int) Math.round((begin + end + 0.0) / 2.0);
        }
        out.println(l);
        out.flush();
        out.close();
        in.close();
    }

    public static boolean f(int l) {
        for (int x = a; x <= b - l + 1; x++) {
            int count = 0;
            for (int i = x; i <= x + l - 1; i++) {
                if (prime[i]) {
                    count++;
                }
            }
            if (count < k) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) throws Exception {
        new Example().run();
    }
}

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;

public class C147 {
	public int[] getPrimeNumbers(int max){
		boolean[] table = getPrimeTable(max);
		int size = 0;
		for(int i = 1; i <= max; i++){
			if(table[i]) size++;
		}
		int[] rets = new int[size];
		int current = 0;
		for(int i = 1; i <= max; i++){
			if(table[i]){
				rets[current++] = i;
			}
		}
		return rets;
	}
	public boolean[] getPrimeTable(int max){
		boolean[] isPrime = new boolean[max+1];
		for(int i = 2; i <= max; i++){
			isPrime[i] = true;
		}
		for(int i = 2; i <= max; i++){
			if(isPrime[i]){
				for(int j = i+i; j <= max; j+=i){
					isPrime[j] = false;
				}
			}
		}
		return isPrime;
	}

	public void solve(){
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		int[] prime = getPrimeNumbers(B);
		int first_prime = 0;
		for(int i = 0; i < prime.length; i++){
			if( prime[i] >= A ){
				first_prime = i;
				break;
			}
		}
		int last_prime = prime.length-1;

		if( K > last_prime +1){
			out.println( -1); out.close();
			return;
		}

		int ans = 0;
//		System.out.println( first_prime + ", " + last_prime + ", " + prime[first_prime] + ", " + prime[last_prime] );
		for(int i = first_prime; i < last_prime - K; i++){
			ans = Math.max(ans, prime[i+K] - (prime[i] + 1)  );
		}
//		System.out.println(ans);
		ans = Math.max(ans, prime[K-1] - A);
//		System.out.println(ans);
		ans = Math.max(ans, B - prime[last_prime - K +1]);
//		System.out.println(ans);
		out.println( ans +1);
		out.close();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new C147().solve();
	}

}

import java.io.*;
import java.util.*;
public class Main{
    static int atoi(String n){return Integer.parseInt(n);}
    static int a,b,k;
    static int cp[];
    static boolean[] criba(int n){
        int fin = (int)Math.sqrt(n)+1;
        boolean p[] = new boolean[n+1];
        p[0] = p[1] = true;
        for(int i=0;i<fin;i++)
            if(!p[i])
                for(int j=i*i;j<p.length;j+=i)
                    p[j] = true;
        return p;
    }
    static boolean puede(int l){
        if(l<k || b-l==0)return false;
        for(int j=0;j<=b-l+1-a;j++){
            int suma = cp[a+j+l-1] - cp[a+j-1];
            //System.out.println(j+" "+suma+" ");
            //System.out.println();
            if(suma<k)return false;
        }
        //System.out.println("retorna true");
        return true;
    }
    static int bs(int cp[]){
        int low = 1, high = b-a+1;
        int last = -1;
        while(low<=high){
            int l = (low+high)>>1;
            //System.out.println("fijo con "+l);
            if(puede(l)){
                high = l-1;
                last = l;
            }
            else
                low = l+1;
        }
        return last;
    }
    public static void main(String jfkd[])throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String div[] = br.readLine().split(" ");
        a = atoi(div[0]);b=atoi(div[1]); k=atoi(div[2]);
        boolean p[] = criba(2*b+1);
        //for(int i=0;i<p.length;i++)
        //  if(!p[i])
        //      System.out.print(i+" ");
        //System.out.println();
        cp = new int[p.length];
        cp[0] = 0;
        for(int i=1;i<cp.length;i++)
            cp[i] += cp[i-1]+(!p[i]?1:0);
        System.out.println(bs(cp));
    }
}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
    public class Main
    {
        public static void main(String[] args)
        {
        Scanner sc =new Scanner(System.in);
        int i=0;
        int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
        int l=0;
        int[] mas = new int[b-a+3];
        i=1;mas[0]=a-1;
        for(int j=a;j<=b;j++)
        {
            if(prost(j)){mas[i]=j;i++;}
        }

        mas[i]=b+1;
        int maxx=0;
        if(i>=c){maxx=-1;System.out.println(-1);System.exit(0);}
        for(int lal=0;lal<=i+1;lal++){}
        for(int max=c;max<=i;max++)
        {

            maxx=Math.max(maxx, mas[max]-mas[max-c]);
        }
        System.out.println(maxx);
    }
        public static boolean prost(int lol)
        {
            boolean lal=true;

            for(int i=2;i<=Math.sqrt(lol);i++)
            {
                if(lol%i==0){lal=false;break;}
            }
            if(lol==1)lal=false;
            return lal;
        }
    }

import java.util.Scanner;

public class PrimesOnInterval {
	static boolean NotPrime[];
	public static boolean solve(int a,int b,int l,int k)
	{
		int count = 0;
		for (int i=a;i<a+l;i++)
		{
			if (!NotPrime[i])
				count++;
		}
		if (count<k)
			return false;
		for (int i=a+l;i<=b;i++)
		{
			if (!NotPrime[i])
				count++;
			if (!NotPrime[i-l])
				count--;
			if (count<k)
				return false;
		}
		return true;
	}
	public static void sieve()
	{
		NotPrime = new boolean[1000001];
		for (int i=2;i<=1000000;i++)
		{
			if (!NotPrime[i])
			{
				for (int j=i+i;j<=1000000;j+=i)
					NotPrime[j] = true;
			}
		}
	}
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int max = 0;
		int count = 0;
		int gap = 0;
		sieve();
		NotPrime[1] = true;
		for (int i=a;i<=b;i++)
			if (!NotPrime[i])
				count++;
		if (count<k)
		{
			System.out.println(-1);
			return;
		}
		int ans = b-a+1, low = 1, high = b-a+1;

		while (low<=high)
		{
			int middle = (low + high)/2;
			if (solve(a, b, middle, k))
			{
				ans = middle;
				high = ans-1;
			}
			else
				low = high+1;
		}
		System.out.println(ans);
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public static void main(String args[]) {

		Scanner scn = new Scanner(System.in);

		int a = scn.nextInt();
		int b = scn.nextInt();

		int k = scn.nextInt();

		ArrayList<Integer> list = SOE(b, a);
		int n = list.size();

		if (n < k) {
			System.out.println(-1);
			return;
		}

		if (n == k) {
			System.out.println(b - a + 1 - Math.min(list.get(0) - a, b - list.get(n - 1)));
			return;
		}
		int ans = list.get(k - 1) - a;

		for (int i = k; i < n; i++) {

			if (list.get(i) - list.get(i - k) > ans) {
				ans = list.get(i) - list.get(i - k);
			}

		}

		if (b - list.get(n - k) > ans) {
			ans = b - list.get(n - k - 1);
		}
		System.out.println(ans);

	}

	public static ArrayList<Integer> SOE(int n, int a) {

		boolean arr[] = new boolean[n + 1];

		Arrays.fill(arr, true);

		for (int table = 2; table * table <= n; table++) {

			if (arr[table] == true) {

				for (int mult = 2; mult * table <= n; mult++) {
					arr[table * mult] = false;
				}
			}
		}

		arr[0] = arr[1] = false;

		ArrayList<Integer> list = new ArrayList<>();

		for (int i = a; i < n + 1; i++) {

			if (arr[i])
				list.add(i);
		}

		return list;

	}

}

import java.util.Scanner;
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.*;

public class C147 {
	static Scanner in = new Scanner(System.in);
	static PrintWriter w = new PrintWriter(System.out, true);

	static int ni() {
		return in.nextInt();
	}

	static String nl() {
		return in.nextLine();
	}

	static void pl(int v) {
		w.println(v);
	}

	static void pl(String s) {
		w.println(s);
	}

	public static void main(String[] args) {
		int a = ni(), b = ni(), k = ni();
		boolean[] e = new boolean[1000001];
		int el = e.length;
		int[] primes = new int[80000];
		int pi = 0;
		for (int i = 2; i < el; i++) {
			if (!e[i]) {
				primes[pi++] = i;
				for (int j = i + i; j < el; j += i)
					e[j] = true;
			}
		}
		int l = Arrays.binarySearch(primes, a);
		if (l < 0) l = -l -1;
		int h = Arrays.binarySearch(primes, b);
		if (h < 0) h = -h -1;
		if (h < pi && primes[h] == b) h++;
		if (h - l < k) {
			pl(-1);
		} else {
			int r = b - primes[h-k] + 1;
			r = Math.max(r, primes[l + k - 1] - a + 1);
			for (int i = l; i < h - k; i++)
				r = Math.max(r, primes[i + k] - primes[i]);
			pl(r);
		}
	}
}

import java.util.*;
import java.io.*;

public class c {

   boolean is(int n) {
      if(n < 2) return false;
      for(int i = 2; i * i <= n; ++i)
         if(n % i == 0)
            return false;
      return true;
   }

   private void solve() throws Exception {
      //BufferedReader br = new BufferedReader(new FileReader("c.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] pa = br.readLine().split(" ");
      int a = Integer.parseInt(pa[0]), b = Integer.parseInt(pa[1]), k = Integer.parseInt(pa[2]), r = 0, s = 0;
      int[] su = new int[b + 1];

      for(int i = 1; i <= b; ++i) {
         if(is(i))
            su[i] = su[i - 1] + 1;
         else
            su[i] = su[i - 1];
      }

      for(int i = a; i <= b; ++i) {
         int c = 0, j = i, d = 0;
         /*for(; j <= b; ++j) {
           c = su[j] - su[i - 1];
           if(c == k)
           break;
           }*/
         int lo = i, hi = b, cu = su[i] - su[i - 1];
         while(lo <= hi) {
            int mid = (hi + lo) / 2, di = su[mid] - su[i];
            if(cu + di < k)
               lo = mid + 1;
            else
               hi = mid - 1;
         }
         s = Math.max(s, lo - i + 1);
         r = Math.max(r, j - i + 1);
      }

      int lo = 0, hi = b - a + 1;

      while(lo <= hi) {
         int mid = (hi + lo) / 2;
         boolean is = true;
         for(int i = a; i + mid <= b; ++i) {
            if(su[i + mid] - su[i] < k)
               is = false;
         }
         if(!is)
            lo = mid + 1;
         else
            hi = mid - 1;
      }

      if(lo <= b - a + 1)
         System.out.println(lo);
      else
         System.out.println(-1);
   }

   public static void main(String[] args) throws Exception {
      new c().solve();
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C147 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int mx = 2000002;
        boolean[] prime = new boolean[mx];
        List<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i < mx; i++) {
            if(prime[i]) continue;
            else primes.add(i);
            for(long j = (long)i * i; j < mx; j += i) {
                prime[(int)j] = true;
            }
        }
        prime[0] = true;
        prime[1] = true;
        int[] ctprimes = new int[mx];
        int ct = 0;
        for(int i = 0; i < mx; i++) {
            if(!prime[i]) ct++;
            ctprimes[i] = ct;
        }
        String[] ss = br.readLine().split(" ");
        int a = Integer.parseInt(ss[0]);
        int b = Integer.parseInt(ss[1]);
        int k = Integer.parseInt(ss[2]);
        int mxg = 1;
        for(int i = 0; i < primes.size() - k; i++) {
            if(primes.get(i + k) > b) break;
            int g = primes.get(i + k) - primes.get(i);
            if(g > mxg) {
                mxg = g;
            }
        }
        for(int l = mxg; l <= b - a + 1; l++) {
            boolean pass = true;
            for(int x = a; x <= b - l + 1; x++) {
                //System.out.println(x + " " + (x + l - 1));
                //System.out.println(ctprimes[x + l - 1] - ctprimes[x] + (prime[x] ? 0 : 1));
                if(ctprimes[x + l - 1] - ctprimes[x] + (prime[x] ? 0 : 1) < k) {
                    pass = false;
                    break;
                }
            }
            if(pass) {
                System.out.println(l);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}

import java.io.*;
import java.util.*;

public class Solution {
    private IO io;
    private int ioMode = -1;
    private String problemName = "";
    private final String mjArgument = "master_j";

    public static void main(String programArguments[]) throws IOException{
        if(programArguments != null && programArguments.length > 0)
            new Solution().run(programArguments[0]);
        else
            new Solution().run(null);
    }

    private void run(String programArgument) throws IOException {
//         _______________________________________________ _________
//        |   Input Mode     |      Output Mode    | mode | comment |
//        |------------------|---------------------|----- |---------|
//        |   input.txt      |      System.out     |  0   |    mj   |
//        |   System.in      |      System.out     |  1   |  T / CF |
//        |<problemName>.in  |  <problemName>.out  |  2   |         |
//        |   input.txt      |      output.txt     |  3   |    C    |
//        |__________________|_____________________|______|_________|
        long nanoTime = 0;
        if(programArgument != null && programArgument.equals(mjArgument)) // mj
            ioMode = 0;
        else if(System.getProperty("ONLINE_JUDGE") != null) // T / CF
            ioMode = 1;
        else
            ioMode = 2;
        switch(ioMode){
            case -1:
                try{
                    throw new Exception("<ioMode> init failure") ;
                }catch (Exception e){
                    e.printStackTrace();
                }
                return;
            case 0:
                break;
            case 1:
                break;
            case 2:
                if(problemName.length() == 0){
                    try{
                        throw new Exception("<problemName> init failure");
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    return;
                }
            case 3:
                break;
        }
        io = new IO(ioMode, problemName);
        if(ioMode == 0){
            System.out.println("File output : \n<start>");
            System.out.flush();
            nanoTime = System.nanoTime();
        }
        solve();
        io.flush();
        if(ioMode == 0){
            System.out.println("</start>");
            long t = System.nanoTime() - nanoTime;
            int d3 = 1000000000, d2 = 1000000, d1 = 1000000;
            if(t>=d3)
                System.out.println(t/d3 + "." + t%d3 + " seconds");
            else if(t>=d2)
                System.out.println(t/d2 + "." + t%d2 + " millis");
            else if(t>=d1)
                System.out.println(t/d1 + "." + t%d1 + " millis");
            System.out.flush();
        }
    }

    private boolean f(int a, int b, int l, int k, int pi[]){
        for(int x = a; x<=b-l+1; x++)
            if(pi[x+l-1] - pi[x-1] < k)
                return false;
        return true;
    }

    private void solve() throws IOException {
        int a = io.nI(), b = io.nI(), k = io.nI(), pi[] = new int[b + 6];
        boolean pr[] = new boolean[pi.length];
        for(int i = 2; i<pr.length; i++)
            for(int j = i*2; j<pr.length; j+=i)
                pr[j] = true;
        for(int i = 2; i<pr.length; i++)
            pi[i] = pi[i - 1] + (!pr[i]? 1 : 0);
//        for(int l = 1; l<=b-a+1; l++)
//            if(f(a, b, l, k, pi)){
//                io.wln(l); return;
//            }
        int lb = 1, rb = b - a + 1; boolean flb, frb;
        if(!((flb = f(a, b, lb, k, pi)) ^ (frb = f(a, b, rb, k, pi))) && pr[lb] && lb!=rb)
            io.wln(-1);
        else{
            while(lb+2 < rb && flb^frb){
                int mb = (lb + rb) / 2;
                boolean fmb = f(a, b, mb, k, pi);
                if(flb^fmb){
                    rb = mb; frb = fmb;
                }else{
                    lb = mb; flb = fmb;
                }
            }
            for(int l = Math.max(1, lb - 2); l <= lb + 2; l++)
                if(f(a, b, l, k, pi)){
                    io.wln(l);
                    return;
                }
            io.wln(-1);
        }
    }//2.2250738585072012e-308

    /**
     * Input-output class
     * @author master_j
     * @version 0.2.3
     */
    @SuppressWarnings("unused")
    private class IO{
        private boolean alwaysFlush;
        StreamTokenizer in; PrintWriter out; BufferedReader br; Reader reader; Writer writer;
        public IO(int ioMode, String problemName) throws IOException{
            Locale.setDefault(Locale.US);
//         _______________________________________________ _________
//        |   Input Mode     |      Output Mode    | mode | comment |
//        |------------------|---------------------|----- |---------|
//        |   input.txt      |      System.out     |  0   |    mj   |
//        |   System.in      |      System.out     |  1   |  T / CF |
//        |<problemName>.in  |  <problemName>.out  |  2   |         |
//        |   input.txt      |      output.txt     |  3   |    C    |
//        |__________________|_____________________|______|_________|
            switch(ioMode){
                case 0:
                    reader = new FileReader("input.txt");
                    writer = new OutputStreamWriter(System.out);
                    break;
                case 1:
                    reader = new InputStreamReader(System.in);
                    writer = new OutputStreamWriter(System.out);
                    break;
                case 2:
                    reader = new FileReader(problemName + ".in");
                    writer = new FileWriter(problemName + ".out");
                    break;
                case 3:
                    reader = new FileReader("input.txt");
                    writer = new FileWriter("output.txt");
                    break;
            }
            br = new BufferedReader(reader);
            in = new StreamTokenizer(br);
            out = new PrintWriter(writer);
            alwaysFlush = false;
        }
        public void setAlwaysFlush(boolean arg){alwaysFlush = arg;}
        public void wln(){out.println(); if(alwaysFlush)flush();}
        public void wln(int arg){out.println(arg); if(alwaysFlush)flush();}
        public void wln(long arg){out.println(arg); if(alwaysFlush)flush();}
        public void wln(double arg){out.println(arg); if(alwaysFlush)flush();}
        public void wln(String arg){out.println(arg); if(alwaysFlush)flush();}
        public void wln(boolean arg){out.println(arg); if(alwaysFlush)flush();}
        public void wln(char arg){out.println(arg); if(alwaysFlush)flush();}
        public void wln(float arg){out.println(arg); if(alwaysFlush)flush();}
        public void wln(Object arg){out.println(arg); if(alwaysFlush)flush();}
        public void w(int arg){out.print(arg); if(alwaysFlush)flush();}
        public void w(long arg){out.print(arg); if(alwaysFlush)flush();}
        public void w(double arg){out.print(arg); if(alwaysFlush)flush();}
        public void w(String arg){out.print(arg); if(alwaysFlush)flush();}
        public void w(boolean arg){out.print(arg); if(alwaysFlush)flush();}
        public void w(char arg){out.print(arg); if(alwaysFlush)flush();}
        public void w(float arg){out.print(arg); if(alwaysFlush)flush();}
        public void w(Object arg){out.print(arg); if(alwaysFlush)flush();}
        public void wf(String format, Object...args){out.printf(format, args); if(alwaysFlush)flush();}
        public void flush(){out.flush();}
        public int nI() throws IOException {in.nextToken(); return(int)in.nval;}
        public long nL() throws IOException {in.nextToken(); return(long)in.nval;}
        public String nS() throws IOException {in.nextToken(); return in.sval;}
        public double nD() throws IOException {in.nextToken(); return in.nval;}
        public float nF() throws IOException {in.nextToken(); return (float)in.nval;}
        public void wc(char...arg){for(char c : arg){in.ordinaryChar(c);in.wordChars(c, c);}}
        public void wc(String arg){wc(arg.toCharArray());}
        public void wc(char arg0, char arg1){in.ordinaryChars(arg0, arg1); in.wordChars(arg0, arg1);}
        public boolean eof(){return in.ttype == StreamTokenizer.TT_EOF;}
        public boolean eol(){return in.ttype == StreamTokenizer.TT_EOL;}
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PrimesOnInterval {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int k = Integer.parseInt(line[2]);

        int l = -1;
        int[] sieve = getSieve(b + 2);
        int casiK = 0;
        int i = a;
        int j = 0;
        while (i <= b) {
            j = i;
            casiK  = 0;
            while (casiK < k && j <= b + 1) {
                if (sieve[j] == 1) casiK++;
                j++;
            }
            if (casiK == k) {
                if (j - i > l) l = j - i;
            }
            i++;
        }
        System.out.println(l);
    }

    public static int[] getSieve(int n) {
        int[] sieve = new int[n];
        sieve[0] = sieve[1] = 0;
        for (int i = 2; i < sieve.length; i++) sieve[i] = 1;
        for (int i = 2; i <= (int) Math.sqrt(n); i++) {
            if (sieve[i] == 1) {
                for (int j = i; i * j < n; j++) {
                    sieve[i * j] = i;
                }
            }
        }
        return sieve;
    }
}

import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a=in.nextInt(),b=in.nextInt(),k=in.nextInt();
        boolean p[]= IntegerUtils.sieve(b+1);
        int c=0,i;
        ArrayList<Integer> x=new ArrayList<Integer>();
        for(i=a;i<=b;i++)
        {
            if(p[i])
            {
                c++;
                x.add(i);
            }
        }
        if(c<k)
        {
            out.println(-1);
            return;
        }
        //DebugUtils.print(c);
        int min=0;
        int start=0,end=k-1;

        min=x.get(k-1)-a+1;
        for(i=a;i<=b;i++)
        {

           /* if(x.size()-k==start)
            {

                if(p[i])
                    min=Math.max(min,b-i+1);
                else
                    min=Math.max(min,b-x.get(start)+1);
                continue;
            }  */

            if(i==x.get(start))
            {

                if(start==x.size()-k)
                {

                        min=Math.max(min,b-i+1);
                    break;
                }
                start++;

                end++;
            }
            min=Math.max(x.get(end)-i+1,min);
        }
        if(k==1)
            min--;
        out.println(min);
	}
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}

class IntegerUtils {
    public static boolean [] sieve(int n)
    {
        boolean prime[]=new boolean[n+1];
        Arrays.fill(prime,true);
        prime[0]=false;
        prime[1]=false;
        int sqrt=(int)Math.sqrt(n);
        for(int i=2;i<=sqrt;i++)
            if(prime[i])
                for(int k=i*i;k<=n;k+=i)
                    prime[k]=false;
        return prime;
    }

    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class C {

    static int n;
    static boolean[] primes;

    public void gen() {

        primes = new boolean[n + 5];
        Arrays.fill(primes, true);

        primes[0] = false;
        primes[1] = false;

        for (int i = 2; i * i <= n; i++)
            if (primes[i])
                for (int j = i * i; j <= n; j += i)
                    primes[j] = false;

    }

    private void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
        int k = nextInt();
        n = 1000000;
        gen();
        int[] p = new int[b - a + 1];
        p[0] = primes[a] ? 1 : 0;
        int c = a + 1;
        for (int i = 1; i < b - a + 1; i++) {
            p[i] = p[i - 1] + (primes[c++] ? 1 : 0);
        }
        int lo = 1, hi = b - a + 1, mid = 0;
        boolean exist = false;
        int iter = 15;
        while (lo <= hi && iter-- > 0) {
            mid = lo + (hi - lo) / 2;
            boolean ok = true;
            for (int i = 0; i + mid - 1 < p.length; i++) {
                if (i - 1 < 0) {
                    if (p[i + mid - 1] < k) {
                        ok = false;
                        break;
                    }
                } else if (p[i + mid - 1] - p[i - 1] < k) {
                    ok = false;
                    break;
                }
            }
            exist |= ok;
            if (ok) {
                hi = mid;
            } else {
                lo = mid + 1;
            }
        }
        pl(!exist ? -1 : hi);
    }

    public static void main(String[] args) {
        new C().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
    public class Main
    {
        public static void main(String[] args)
        {
        Scanner sc =new Scanner(System.in);
        int i=0;
        int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
        int l=0;
        int[] mas = new int[b-a+3];
        i=1;mas[0]=a-1;
        for(int j=a;j<=b;j++)
        {
            if(prost(j)){mas[i]=j;i++;}
        }

        mas[i]=b+1;
        int maxx=0;

        for(int max=c;max<=i;max++)
        {

            maxx=Math.max(maxx, mas[max]-mas[max-c]);
        }
        if(maxx>=mas[i]-mas[0])maxx=-1;
        System.out.println(maxx);
    }
        public static boolean prost(int lol)
        {
            boolean lal=true;

            for(int i=2;i<=Math.sqrt(lol);i++)
            {
                if(lol%i==0){lal=false;break;}
            }
            if(lol==1)lal=false;
            return lal;
        }
    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A{
	static InputReader in = new InputReader(System.in);
	static int arr[];
	static int b,a,k;
	static boolean isPrime[] = new boolean[(int)10e6+2];
	static int N = (int)10e6+1;

	static void sieve(){
		Arrays.fill(isPrime,true);
		isPrime[0] = false;
		isPrime[1] = false;
		for(int i=2;i*i<=N;i++){
			if(isPrime[i]){
				for(int j=i*2;j<=N;j+=i){
					isPrime[j] = false;
				}
			}
		}
	}

	static boolean P(int l){
		int cnt = 0;
		for(int i=0;i<l-1;i++){
			if(isPrime[a+i])cnt++;
		}
		if(cnt>=k) return true;
		else return false;

	}
	public static void main(String[]args)throws Throwable{
		a = in.j(); b = in.j(); k =in.j(); sieve();
		int lo = 1;
		int hi = b-a+1;
		int r = -1;
		while(lo<=hi){
			int mid = lo+(hi-lo)/2;
			if(P(mid)){
				hi = lo-1;
				r = mid;
			}
			else lo = mid+1;
		}
		System.out.println(r);
	}

	static	class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int j() {
			return Integer.parseInt(next());
		}
		public long readLong(){
			return Long.parseLong(next());
		}

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Primes {
	static public void main(String[] args) throws IOException{
		BufferedReader br;
		br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] split = line.split(" ");
		int a = Integer.parseInt(split[0]);
		int b = Integer.parseInt(split[1]);
		int k = Integer.parseInt(split[2]);
		int i,j,p,min=-1,cont=0;

		boolean[] criba = new boolean[b+2];
		//System.out.println(criba[0]);
		int[] sum = new int[b+2];
		Arrays.fill(criba,true);
		criba[0] = false;
		criba[1] = false; //1

		for (i=4;i<=b+1;i=i+2){ //pares
			criba[i]=false;
		}

		for (i=3;i*i<=b+1;i=i+2){
			p =i+i;
			for (j=i+p;j<=b+1;j=j+p){
				criba[j]=false;
			}
		}

		if (criba[b+1])
			sum[b+1]=1;

		for (i=b;i>=a;i--){
			if (criba[i])
				sum[i]++;
			sum[i]+=sum[i+1];
		}
		//for (i=a;i<=b;i++){
			//System.out.println(sum[i] + " "+ criba[i]);
		//}
		int l=1;
		min=-1;
		for (i=a;i<=b-l+1;i++){
			//System.out.println(i);
			while (sum[i]-sum[i+l]<k){
				l++;
				if (i+l>b){
					System.out.println(min);
					System.exit(0);
				}
			}

			min = b-i+1;
			//System.out.println(min);
		}

		System.out.println(min);
	}
}

import java.util.Scanner;
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.*;

public class C147 {
	static Scanner in = new Scanner(System.in);
	static PrintWriter w = new PrintWriter(System.out, true);

	static int ni() {
		return in.nextInt();
	}

	static String nl() {
		return in.nextLine();
	}

	static void pl(int v) {
		w.println(v);
	}

	static void pl(String s) {
		w.println(s);
	}

	public static void main(String[] args) {
		int a = ni(), b = ni(), k = ni();
		boolean[] e = new boolean[1000001];
		int el = e.length;
		int[] primes = new int[80000];
		int pi = 0;
		for (int i = 2; i < el; i++) {
			if (!e[i]) {
				primes[pi++] = i;
				for (int j = i + i; j < el; j += i)
					e[j] = true;
			}
		}
		int l = Arrays.binarySearch(primes, a);
		if (l < 0) l = -l -1;
		int h = Arrays.binarySearch(primes, b);
		if (h < 0) h = -h -1;
		if (h - l < k) {
			pl(-1);
		} else {
			int r = b - primes[h-k] + 1;
			r = Math.max(r, primes[l + k - 1] - a + 1);
			for (int i = l; i < h - k; i++)
				r = Math.max(r, primes[i + k] - primes[i]);
			pl(r);
		}
	}
}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
    public class Main
    {
        public static void main(String[] args)
        {
        Scanner sc =new Scanner(System.in);
        int i=0;
        int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
        int l=0;
        int[] mas = new int[b-a+3];
        i=1;mas[0]=a-1;
        for(int j=a;j<=b;j++)
        {
            if(prost(j)){mas[i]=j;i++;}
        }

        mas[i]=b+1;
        int maxx=0;
        if(i>c){maxx=-1;System.out.println(-1);System.exit(0);}
        for(int lal=0;lal<=i+1;lal++){}
        for(int max=c;max<=i;max++)
        {

            maxx=Math.max(maxx, mas[max]-mas[max-c]);
        }
        System.out.println(maxx);
    }
        public static boolean prost(int lol)
        {
            boolean lal=true;

            for(int i=2;i<=Math.sqrt(lol);i++)
            {
                if(lol%i==0){lal=false;break;}
            }
            if(lol==1)lal=false;
            return lal;
        }
    }

import java.util.*;
import java.io.*;
public class C {
	List<Integer> prime;

	public void solve() throws IOException {
		prime = new ArrayList<Integer>();
		prime.add(2);
		int[] sum = new int[1200001];
		for(int i = 3; i < sum.length; i++){
			if( i%2 == 0 ){
				sum[i] = sum[i-1];
				continue;
			}
			boolean flag = true;
			for(Integer p : prime){
				if( p > Math.sqrt(i) ){
					prime.add(i);
					break;
				}
				if( i%p == 0 ){
					flag = false;
					break;
				}
			}
			if( flag ){
				sum[i] = sum[i-1]+1;
			} else {
				sum[i] = sum[i-1];
			}
		}
		int a = nextInt();
		int b = nextInt();
		int k = nextInt();
		for(int i = a; i < b; i++){
			if( sum[i]-sum[a-1] >= k ){
				int ans = i-a;
				int id = a+1;
				while( id <= b-ans+1 ){
					if( sum[id+ans-1]-sum[id-1] >= k ){
						id++;
					} else {
						ans++;
					}
				}
				writer.println(ans);
				return;
			}
		}
		writer.println(-1);
	}

	public static void main(String[] args) throws IOException {
		new C().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author mdonaj
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();

        boolean[] primes = new boolean[b+10];
        Arrays.fill(primes, true);
        primes[0] = false;
        primes[1] = false;

        for(int i = 2; i <= b; ++i) {
            if(!primes[i])
                continue;
            int c = i;

            for(int j = i + c; j <= b; j += c)
                primes[j] = false;
        }

        int[] cnt = new int[b+1];
        int curr = 0;
        for(int i = 0; i <= b; ++i) {
            if(primes[i])
                curr++;
            cnt[i] = curr;
        }

        int l = -1;
        for(int i = a; i <= b; ++i) {
            if(a + l > b)
                break;

            int next = k+cnt[i];
            if(primes[i])
                next--;

            int idx = Arrays.binarySearch(cnt, next);
            if(idx < 0 && l > 0) {
                l = b-a+1;
                break;
            }

            if(idx < 0 || idx > b)
                break;

            if(idx != 0 && cnt[idx] == cnt[idx -1]) idx--;
            l = Math.max(l, idx - i + 1);
        }

        out.println(l);

	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner scn = new Scanner(System.in);

		int a = scn.nextInt();
		int b = scn.nextInt();

		int k = scn.nextInt();

		ArrayList<Integer> list = SOE(b, a);
		int n = list.size();

		if (n < k) {
			System.out.println(-1);
			return;
		}

		if (n == k) {
			System.out.println(b - a + 1 - Math.min(list.get(0) - a, b - list.get(n - 1)));
			return;
		}
		int ans = list.get(k - 1) - a;

		for (int i = k; i < n; i++) {

			if (list.get(i) - list.get(i - k) > ans) {
				ans = list.get(i) - list.get(i - k);
			}

		}
		System.out.println(ans);

	}

	public static ArrayList<Integer> SOE(int n, int a) {

		boolean arr[] = new boolean[n + 1];

		Arrays.fill(arr, true);

		for (int table = 2; table * table <= n; table++) {

			if (arr[table] == true) {

				for (int mult = 2; mult * table <= n; mult++) {
					arr[table * mult] = false;
				}
			}
		}

		arr[0] = arr[1] = false;

		ArrayList<Integer> list = new ArrayList<>();

		for (int i = a; i < n + 1; i++) {

			if (arr[i])
				list.add(i);
		}

		return list;

	}

}

import java.io.*;
import java.math.*;
import java.util.*;

public class SolutionA{

	public static void main(String[] args){
		new SolutionA().run();
	}
	int dp[];
	int ax[];
	void solve(){
		int a = in.nextInt();
		int b = in.nextInt();
		int k = in.nextInt();
		boolean is_p[] = new boolean[1000100];
		for(int i = 3; i< 1000; i+=2){
			if(!is_p[i]){
				for(int j = i * i; j < is_p.length; j+=i){
					is_p[j] = true;
				}
			}
		}
		for(int i = 4; i<is_p.length; i+=2) is_p[i] = true;
		ArrayList<Integer> arr = new ArrayList<Integer>();
		for(int i = a; i<=b; i++) if(!is_p[i]) arr.add(i);
		if(arr.size() < k){
			out.println(-1);
		}
		else {
			int mi = arr.get(k-1) - a + 1;
			int prev = arr.get(0);
			for(int i = k; i<arr.size(); ++i){
				mi = Math.max(arr.get(i) - prev, mi);
				prev = arr.get(i - k + 1);
			}
			mi = Math.max(b - prev + 1, mi);
			out.println(mi);
		}
	}

	class Pair implements Comparable<Pair>{
		int x, y;
		Pair(int x, int y){
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(Pair o) {
			if(o.x == x) return ((Integer) y).compareTo(o.y);
			return ((Integer) x).compareTo(o.x);
		}

	}
	FastScanner in;
	PrintWriter out;
	void run(){
		in = new FastScanner(System.in);
		out = new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		out.close();
	}

	void runIO(){
		try{
			in = new FastScanner(new File("expr.in"));
			out = new PrintWriter(new FileWriter(new File("expr.out")));
			solve();
			out.close();
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}
	class FastScanner{
		BufferedReader bf;
		StringTokenizer st;
		public FastScanner(File f){
			try{
				bf = new BufferedReader(new FileReader(f));
			}
			catch(IOException ex){
				ex.printStackTrace();
			}
		}
		public FastScanner(InputStream is){
			bf = new BufferedReader(new InputStreamReader(is));
		}
		String next(){
			while(st == null || !st.hasMoreTokens()){
				try{
					st = new StringTokenizer(bf.readLine());
				}
				catch(IOException ex){
					ex.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		float nextFloat(){
			return Float.parseFloat(next());
		}
		String nextLine(){
			try{
				return bf.readLine();
			}
			catch(Exception ex){
				ex.printStackTrace();
			}
			return "";
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		BigInteger nextBigInteger(){
			return new BigInteger(next());
		}
		BigDecimal nextBigDecimal(){
			return new BigDecimal(next());
		}
		int[] nextIntArray(int n){
			int a[] = new int[n];
			for(int i = 0; i < n; i++)
				a[i] = Integer.parseInt(next());
			return a;
		}
		long[] nextLongArray(int n){
			long a[] = new long[n];
			for(int i = 0; i < n; i++)
				a[i] = Long.parseLong(next());
			return a;
		}
	}
}

import java.io.*;
import java.util.*;
public final class primes_on_interval
{
	static Scanner sc=new Scanner(System.in);
	static PrintWriter out=new PrintWriter(System.out);
	static List<Integer> list=new ArrayList<Integer>();
	static int[] arr;
	static int maxn=(int)Math.pow(10,6);

	static void mark(int num,int max)
	{
		int i=2,elem;
		while((elem=(i*num))<=max)
		{
			arr[elem-1]=1;
			i++;
		}
	}

	static void build()
	{
		for(int i=1;i<arr.length-1;i++)
		{
			if(arr[i]==0)
			{
				mark(i+1,arr.length-1);
				list.add(i+1);
			}
		}
	}

	static void solve(int a,int b,int len,int k)
	{
		if(a>list.get(list.size()-1))
		{
			out.println("-1");
		}
		else
		{
			PriorityQueue<Integer> pq=new PriorityQueue<Integer>();
			int i;
			for(i=1;(i*i)<len;i++)
			{
				if(len%i==0)
				{
					pq.add(i);
					pq.add(len/i);
				}
			}
			if(i*i==len)
			{
				pq.add(i);
			}
			int pos=Collections.binarySearch(list,a);
			if(pos<0)
			{
				pos++;
				pos*=-1;
			}
			int max=-1;
			boolean ans=true;
			outer:
			while(pq.size()>0)
			{
				int c=0;
				int innerpos=pos;
				int f=0;
				int size=pq.poll();
				inner:
				for(i=a;i<=b;i++)
				{
					if(i==list.get(innerpos))
					{
						innerpos++;
						f++;
					}
					c++;
					if(c==size)
					{
						if(f<k)
						{
							ans=false;
							break;
						}
						else
						{
							c=0;
							f=0;
							continue;
						}
					}
				}
				if(!ans)
				{
					ans=true;
					continue;
				}
				else
				{
					max=size;
					break;
				}
			}
			out.println(max);
		}
	}

	public static void main(String args[]) throws Exception
	{
		arr=new int[maxn];
		build();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int k=sc.nextInt();
		int len=b-a+1;
		solve(a,b,len,k);
		out.close();
	}
}

import java.util.Scanner;
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.*;

public class C147 {
	static Scanner in = new Scanner(System.in);
	static PrintWriter w = new PrintWriter(System.out, true);

	static int ni() {
		return in.nextInt();
	}

	static String nl() {
		return in.nextLine();
	}

	static void pl(int v) {
		w.println(v);
	}

	static void pl(String s) {
		w.println(s);
	}

	public static void main(String[] args) {
		int a = ni(), b = ni(), k = ni();
		boolean[] e = new boolean[1000001];
		int el = e.length;
		int[] primes = new int[80000];
		int pi = 0;
		for (int i = 2; i < el; i++) {
			if (!e[i]) {
				primes[pi++] = i;
				for (int j = i + i; j < el; j += i)
					e[j] = true;
			}
		}
		int l = Arrays.binarySearch(primes, a);
		if (l < 0) l = -l -1;
		int h = Arrays.binarySearch(primes, b);
		if (h < 0) h = -h -1;
		if (h < pi && primes[h] == b) h++;
		if (h - l < k) {
			pl(-1);
		} else {
			int r = b - primes[h-k] + 1;
			r = Math.max(r, primes[l + k - 1] - a + 1);
			for (int i = l; i < h - k; i++)
				r = Math.max(r, primes[i + k] - primes[i]);
			pl(r);
		}
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public static void main(String args[]) {

		Scanner scn = new Scanner(System.in);

		int a = scn.nextInt();
		int b = scn.nextInt();

		int k = scn.nextInt();

		ArrayList<Integer> list = SOE(b, a);
		int n = list.size();

		if (n < k) {
			System.out.println(-1);
			return;
		}

		if (n == k) {
			System.out.println(b - a + 1);
			return;
		}
		int ans = list.get(k - 1) - a;

		for (int i = k; i < n; i++) {

			if (list.get(i) - list.get(i - k) > ans) {
				ans = list.get(i) - list.get(i - k);
			}

		}
		System.out.println(ans);

	}

	public static ArrayList<Integer> SOE(int n, int a) {

		boolean arr[] = new boolean[n + 1];

		Arrays.fill(arr, true);

		for (int table = 2; table * table <= n; table++) {

			if (arr[table] == true) {

				for (int mult = 2; mult * table <= n; mult++) {
					arr[table * mult] = false;
				}
			}
		}

		arr[0] = arr[1] = false;

		ArrayList<Integer> list = new ArrayList<>();

		for (int i = a; i < n + 1; i++) {

			if (arr[i])
				list.add(i);
		}

		return list;

	}

}

import java.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class Start {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    public static void main(String[] args) {
        new Start().run();
    }

    public static void mergeSort(int[] a) {
        mergeSort(a, 0, a.length - 1);
    }

    private static void mergeSort(int[] a, int levtIndex, int rightIndex) {
        final int MAGIC_VALUE = 50;
        if (levtIndex < rightIndex) {
            if (rightIndex - levtIndex <= MAGIC_VALUE) {
                insertionSort(a, levtIndex, rightIndex);
            } else {
                int middleIndex = (levtIndex + rightIndex) / 2;
                mergeSort(a, levtIndex, middleIndex);
                mergeSort(a, middleIndex + 1, rightIndex);
                merge(a, levtIndex, middleIndex, rightIndex);
            }
        }
    }

    private static void merge(int[] a, int levtIndex, int middleIndex,
            int rightIndex) {
        int length1 = middleIndex - levtIndex + 1;
        int length2 = rightIndex - middleIndex;
        int[] levtArray = new int[length1];
        int[] rightArray = new int[length2];
        System.arraycopy(a, levtIndex, levtArray, 0, length1);
        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
        for (int k = levtIndex, i = 0, j = 0; k <= rightIndex; k++) {
            if (i == length1) {
                a[k] = rightArray[j++];
            } else if (j == length2) {
                a[k] = levtArray[i++];
            } else {
                a[k] = levtArray[i] <= rightArray[j] ? levtArray[i++]
                        : rightArray[j++];
            }
        }
    }

    private static void insertionSort(int[] a, int levtIndex, int rightIndex) {
        for (int i = levtIndex + 1; i <= rightIndex; i++) {
            int current = a[i];
            int j = i - 1;
            while (j >= levtIndex && a[j] > current) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = current;
        }
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    class LOL implements Comparable<LOL> {
        int x;
        int y;

        public LOL(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(LOL o) {
           //   return x - o.x; // ---->
            // return o.x - x; // <----
            return  y - o.y;
        }

    }

    public void solve() throws IOException {

        int a = readInt();
        int b = readInt();
        int k = readInt();

        ArrayList<Integer> prime = new ArrayList<Integer>();
        int n = 2*b;
        boolean used []  = new boolean [n+1];
        Arrays.fill(used, true);
        used[0]=used[1]=false;
        for (int i =2; i<=n; i++){
            if (used[i]){
                for (int j = i*i; j<=n; j+=i)
                        if (j>0 && j<=n)
                            used[j]=false;
                        else break;
            }
        }

        for (int i =2; i<=n; i++) {
            if (used[i]) prime.add(i);
        }

        int  t = 0;

        int left = 1;
        int right = b-a+1;
        boolean yes = true;
        int l = (left+right)/2;
        boolean first = true;
        int ololo = 0;
    a:  while(left<=right){
        if (!first){
            if (yes){
                right = l-1;
            }
            else {
                left = l+1;
            }
             l = (left+right)/2;
        }
        else {
            first = false;
        }
        if (b-a >50000){
            ololo = b - l;
        }
    //a:    for (int l = 1; l <= b-a+1;l++){
    b:      for (int x = b-l+1; x >=a+ololo;  x--){
                for (int i = 0; i < prime.size(); i++){
                    if (x<=prime.get(i)){
                        t = 0;
                        for (int j = i; j < prime.size(); j++){
                            if (x+l-1 <= prime.get(j)){
                                if (x+l-1 == prime.get(j)) t++;
                                if (j-i+t>=k){
                                    yes = true;
                                    continue b;
                                }
                                else {
                                    yes = false;
                                    continue a;
                                }
                            }
                        }
                        yes = false;
                        continue a;
                    }
                }
                yes = false;
                continue a;
            }
            out.print(l);
            return;
        }
        out.print(-1);
    }

}

import java.io.*;
import java.util.*;
public class Main{
    static int atoi(String n){return Integer.parseInt(n);}
    static int a,b,k;
    static int cp[];
    static boolean[] criba(int n){
        int fin = (int)Math.sqrt(n)+1;
        boolean p[] = new boolean[n+1];
        p[0] = p[1] = true;
        for(int i=0;i<fin;i++)
            if(!p[i])
                for(int j=i*i;j<p.length;j+=i)
                    p[j] = true;
        return p;
    }
    static boolean puede(int l){
        if(l<k || b-l==0)return false;
        for(int i=0,j=0;i<b-l;i++,j++){
            int suma = cp[a+j+l-1] - cp[a+j-1];
            //System.out.println(j+" "+suma+" ");
            //System.out.println();
            if(suma<k)return false;
        }
        //System.out.println("retorna true");
        return true;
    }
    static int bs(int cp[]){
        int low = 1, high = b-a+1;
        int last = -1;
        while(low<=high){
            int l = (low+high)>>1;
            //System.out.println("fijo con "+l);
            if(puede(l)){
                high = l-1;
                last = l;
            }
            else
                low = l+1;
        }
        return last;
    }
    public static void main(String jfkd[])throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String div[] = br.readLine().split(" ");
        a = atoi(div[0]);b=atoi(div[1]); k=atoi(div[2]);
        boolean p[] = criba(2*b+1);
        //for(int i=0;i<p.length;i++)
        //  if(!p[i])
        //      System.out.print(i+" ");
        //System.out.println();
        cp = new int[p.length];
        cp[0] = 0;
        for(int i=1;i<cp.length;i++)
            cp[i] += cp[i-1]+(!p[i]?1:0);
        System.out.println(bs(cp));
    }
}

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Tolik
 */
public class Codeforces1 {
    public static int[] readIntMas1(){
        Scanner sc = new Scanner(System.in);
        int[] input = new int[sc.nextInt()];
        for (int i = 0; i < input.length; i ++){
            input[i] = sc.nextInt();
        }
        return input;
    }

    public static int[][] readIntMas2(){
        Scanner sc = new Scanner(System.in);
        int[][] input = new int[sc.nextInt()][sc.nextInt()];
        for (int i = 0; i < input.length; i ++){
            for (int j = 0; j < input[j].length; j++){
                input[i][j] = sc.nextInt();
            }
        }
        return input;
    }

    public static int[] readStringToIntWithDigits(){
        Scanner sc = new Scanner(System.in);
        String tmp = sc.nextLine();
        int[] input = new int[tmp.length()];
        for (int i = 0; i < input.length; i++){
            input[i] = Integer.parseInt(String.valueOf(tmp.charAt(i)));
        }
        return input;
    }

    public static int[] readStringToIntWithoutDigits(){
        Scanner sc = new Scanner(System.in);
        String tmp = sc.nextLine();
        int[] input = new int[tmp.length()];
        for (int i = 0; i < input.length; i++){
            if (tmp.charAt(i) == 'a'){
                input[i] = 0;
            } else{
                input[i] = 1;
            }
        }
        return input;
    }

    public static int[][] readStringToIntWithoutDigits2(int n, int m){
        Scanner sc = new Scanner(System.in);
        int[][] input = new int[n][m];
        for (int i = 0; i < n; i++){
            String tmp = sc.nextLine();
            for (int j = 0; j < n; j++){
                if (tmp.charAt(j) == 'a'){
                    input[i][j] = 0;
                } else{
                    input[i][j] = 1;
                }
            }
        }
        return input;
    }

    static int g(int x){
        return x ^ (x >> 1);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 1000001;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        boolean[] ar = new boolean[n];
        for (int i = 0; i < n; i ++){
            ar[i] = true;
        }
        ar[0] = ar[1] = false;
        for (int i=2; i<n; ++i)
    if (ar[i])
        if (((long)i) * i < n)
            for (long j=i*i; j<n; j+=i)
                ar[(int)j] = false;
        int[]ar2 = new int [n];
        ar2[0]  = 0;
        for (int i = 1; i < n; i++){
            if (ar[i]){
                ar2[i] = ar2[i-1] + 1;
            } else{
                ar2[i] = ar2[i-1];
            }
        }
        boolean flag = false;

        for (int l = k; l <= b - a + 1; l++){
            boolean flag2 = true;
            int x = a;
            for (; x <= b - l + 1; x++){
                for (; ar2[x+l-1] - ar2[x - 1] < k && (x+l - 1 )<n;l++);
           /*     if (ar2[x+l-1] - ar2[x - 1] < k){
                    flag2 = false;
                    break;
                }*/

            }

                if (l <= b - a + 1){
                    flag = true;
                    System.out.println(l);
                    break;
                }
            }
       if (!flag){
           System.out.println(-1);
       }

    }
}

import java.util.*;
import java.io.*;

public class Codeforces {

    static int arr[];

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        int a = Reader.nextInt(), b = Reader.nextInt(), k = Reader.nextInt();
        boolean p[] = new boolean[b+1];
        arr = new int[b+1];
        int count = 0;

        for(int i = 2; i  <= b; i++){
            if(!p[i]){
                count++;
                for(int j = i; (long)(j) * i <= b; j++)
                    p[j * i] = true;
            }

            arr[i] = count;
        }

        int last = b-a+1, first = 1, ans = 999999999;
        while(last >= first){
            int mid = (last + first) / 2;
            if(check(a,b,mid,k)){
                last = mid - 1;
                ans = mid;
            }

            else
                first = mid + 1;
        }

        if(ans == -1)
            System.out.println("-1");

        else
         System.out.println(ans);
   }

   public static boolean check(int a, int b, int l, int k){
       int lim = b - l + 1;

       for(int i = a; i <= lim; i++)
           if(arr[i + l - 1] - arr[i-1] < k)
              return false;

       return true;
   }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /**
     * call this method to initialize reader for InputStream
     */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static byte nextByte() throws IOException {

        return Byte.parseByte(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

//package sheet_C;
import java.io.*;
import java.util.*;
public class PrimesOnInterval {

	static int a;

	static ArrayList<Integer> primes;
	static boolean[] isComposite;

	public static void main(String[]args)throws Throwable{
		PrintWriter pw=new PrintWriter(System.out,true);
		MyScanner sc=new MyScanner();

		a=sc.nextInt();
		int b=sc.nextInt();
		int k=sc.nextInt();
		sieve(b);

		int ans=-1;
		int n=primes.size();

		if(n<k){
			pw.println(ans);
			return;
		}

		for(int i=0;i<n-k;i++){
			ans=Math.max(ans, primes.get(i+k)-primes.get(i));
		}

		if(isComposite[a])
			ans=Math.max(ans, primes.get(k-1)-a+1);
		else
			if(k<n)
				ans=Math.max(ans, primes.get(k)-a+1);
			else
				ans=Math.max(ans, b-a+1);

		if(isComposite[b])
			ans=Math.max(ans, b-primes.get(n-k)+1);
		else
			if(n-k-1>=0)
				ans=Math.max(ans, b-primes.get(n-k-1)+1);
			else
				ans=Math.max(ans, b-a+1);

		pw.println(ans);

		pw.flush();
		pw.close();
	}

	static void sieve(int N)
	{
		isComposite = new boolean[N+1];
		isComposite[0] = isComposite[1] = true;
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i)
			if (isComposite[i] == false)
			{
				if(i>=a)
					primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)
						isComposite[j] = true;
			}
	}

	static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;

	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }

	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }

	      int nextInt() {
	          return Integer.parseInt(next());
	      }

	      long nextLong() {
	          return Long.parseLong(next());
	      }

	      double nextDouble() {
	          return Double.parseDouble(next());
	      }

	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }
}

import java.util.*;
//import java.math.*;
/*Author LAVLESH*/
public class solution
{  static int count=0;
	static boolean[]sieve(int n,int A){
		boolean[]a=new boolean[n+1];
		for(int i=0;i<=n;i++)a[i]=true;
		a[0]=false;
		a[1]=false;
		for(long j=2;j<=n;j++){
			if(a[(int)j]){if(j>=A)count++;
				for(long k=j*j;k<=n;k+=j)
					a[(int)k]=false;
			}
		}
		return a;
	}
	public static void main(String[]args){

		Scanner in=new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		int k=in.nextInt();
		int l,x=0,i,max=0;
		boolean[]bl=sieve(b,a);
		int []prime=new int[count+2];
		//System.out.println(count);
		int j=1;
		prime[0]=a;
		for( i=a;i<=b;i++){
			if(bl[i]){prime[j]=i;
			j++;}
		}
		prime[j]=b;
		if(count<k){System.out.print("-1");return;}

		for(i=0;i<=(count+1-k);i++){
			if(prime[i+k]-prime[i]>max)
				{max=prime[i+k]-prime[i];x=i+k;}
		}
		if(x==count+1||x-k==0)
		System.out.print(max+1);
		else System.out.print(max);

}}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C147 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int mx = 2000002;
        boolean[] prime = new boolean[mx];
        List<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i < mx; i++) {
            if(prime[i]) continue;
            else primes.add(i);
            for(long j = (long)i * i; j < mx; j += i) {
                prime[(int)j] = true;
            }
        }
        prime[0] = true;
        prime[1] = true;
        int[] ctprimes = new int[mx];
        int ct = 0;
        for(int i = 0; i < mx; i++) {
            if(!prime[i]) ct++;
            ctprimes[i] = ct;
        }
        String[] ss = br.readLine().split(" ");
        int a = Integer.parseInt(ss[0]);
        int b = Integer.parseInt(ss[1]);
        int k = Integer.parseInt(ss[2]);
        int mxg = 1;
        for(int i = 0; i < primes.size() - k - 1; i++) {
            if(primes.get(i + k - 1) > b) break;
            int g = primes.get(i + k - 1) - primes.get(i);
            if(g > mxg) {
                mxg = g;
            }
        }
        for(int l = mxg; l <= b - a + 1; l++) {
            boolean pass = true;
            for(int x = a; x <= b - l + 1; x++) {
                //System.out.println(x + " " + (x + l - 1));
                //System.out.println(ctprimes[x + l - 1] - ctprimes[x] + (prime[x] ? 0 : 1));
                if(ctprimes[x + l - 1] - ctprimes[x] + (prime[x] ? 0 : 1) < k) {
                    pass = false;
                    break;
                }
            }
            if(pass) {
                System.out.println(l);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}

import java.util.*;
public  class Solution{
	//sieve
	public static boolean[] sieve(){
		int MAX=1000002;

		boolean[] prime=new boolean[MAX+1];
		for(int i=0;i<=MAX;i++)
			prime[i]=true;
		prime[0]=false;
		prime[1]=false;
		for(int i=2;i*i<=MAX;i++)
		{
			if(prime[i]==true)
				{for(int j=i*i;j<=MAX;j+=i)
					prime[j]=false;}
		}
		return prime;
	}

	//main
	public static void main(String[] args){
		int MAX=1000002;
    Scanner in=new Scanner(System.in);
     int a=in.nextInt();
     int b=in.nextInt();
     int k=in.nextInt();
     int i=0,count=0;
     boolean[] prime=new boolean[MAX+1];
     prime=sieve();
	 int sum=0,temp=0,max=a-1;
	 for(i=a;i<=b;i++){
		 if(temp==k)
		 {   temp=0;
			 if(sum<i-max)
				 sum=i-max;
			 max=i;
		 }
		 if(prime[i]==true)
		 {
			 temp++;
		 }
	 }
	 if(sum==0)
		 sum=-1;
	System.out.println(sum);
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C147 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int mx = 2000002;
        boolean[] prime = new boolean[mx];
        List<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i < mx; i++) {
            if(prime[i]) continue;
            else primes.add(i);
            for(long j = (long)i * i; j < mx; j += i) {
                prime[(int)j] = true;
            }
        }
        prime[0] = true;
        prime[1] = true;
        int[] ctprimes = new int[mx];
        int ct = 0;
        for(int i = 0; i < mx; i++) {
            if(!prime[i]) ct++;
            ctprimes[i] = ct;
        }
        String[] ss = br.readLine().split(" ");
        int a = Integer.parseInt(ss[0]);
        int b = Integer.parseInt(ss[1]);
        int k = Integer.parseInt(ss[2]);
        int mxg = 101;
        for(int i = 0; i < primes.size() - k - 1; i++) {
            if(primes.get(i + k - 1) > b) break;
            int g = primes.get(i + k - 1) - primes.get(i);
            if(g > mxg) {
                mxg = g;
            }
        }
        for(int l = mxg - 100; l <= b - a + 1; l++) {
            boolean pass = true;
            for(int x = a; pass && x <= b - l + 1; x++) {
                if(ctprimes[x + l - 1] - ctprimes[x] + (prime[x] ? 0 : 1) < k)
                    pass = false;
            }
            if(pass) {
                System.out.println(l);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Primes {

    static int[] numeros = new int[1000010];
    static int[] primos = new int[1000010];

    public static void fill() {
        for (int i = 2; i < 1000010; i++) {
            if (numeros[i] == 0) {
                numeros[i] = -1;
                for (int j = i; j < 1000010 / i; j++) {
                    numeros[j * i] = i;
                }
            }
        }
        primos[0] = 0;
        for (int i = 1; i < 1000010; i++) {
            if (numeros[i] == -1)
                primos[i] = primos[i - 1] + 1;
            else
                primos[i] = primos[i - 1];
        }
    }

    public static boolean sirve(int l, int a, int b, int k) {
        for (int i = a; i <= b - l + 1; i++) {
            if (primos[i + l - 1] - primos[i - 1] < k) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        fill();
        int A = 1, B = b - a + 1, mid;
        while (A < B) {
            mid = A + (B - A) / 2;
            if (sirve(mid, a, b, k)) {
                B = mid;
            } else {
                A = mid + 1;
            }
        }
        if (!sirve(A, a, b, k)) System.out.println(-1);
        else System.out.println(A);
    }
}

import java.util.*;

public class p237C {
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();
        int[] s = sieve(b);

        int s1 = 0;
        int i = a;
        while (i<(b+1) && s1<k)
        {
            s1+=s[i];
            i++;
        }
        if (i==(b+1))
        {
            System.out.print(-1);
            return;
        }
        int l = i-a;

        while (l<=b-a+1)
        {
            int sum = 0;
            for (i = a; i < l+a; i++)
                sum+=s[i];
            if (sum<k)
            {
                l++;
                continue;
            }

            boolean check = true;
            for (int x = a; x <= b-l; x++)
            {
                sum=sum-s[x]+s[x+l];
                if (sum<k)
                    check=false;
            }
            if (!check)
            {
                l++;
                continue;
            }

            else
            {
                System.out.print(l);
                return;
            }

        }

        System.out.print(-1);

    }

    // returns a sieve of primes up to m
    public static int[] sieve(int m)
    {
        int[] s = new int[m+1];
        for (int i = 0; i < m+1; i++)
            s[i] = 1;
        s[0] = 0;
        s[1] = 0;
        for (int i = 2; i < m+1; i++)
        {
            if (s[i]==1)
            {
                for (int j = 2*i; j < m+1; j+=i)
                    s[j] = 0;
            }
        }

         return s;
    }

}

import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a=in.nextInt(),b=in.nextInt(),k=in.nextInt();
        boolean p[]= IntegerUtils.sieve(b+1);
        int c=0,i;
        ArrayList<Integer> x=new ArrayList<Integer>();
        for(i=a;i<=b;i++)
        {
            if(p[i])
            {
                c++;
                x.add(i);
            }
        }
        if(c<k)
        {
            out.println(-1);
            return;
        }
        DebugUtils.print(c);
        int min=0;
        int start=0,end=k-1;
        for(i=a;i<=b;i++)
        {

            if(start==x.size()-k)
                            {
                                min=Math.max(min,b-x.get(start)+1);
                                break;
                            }
            if(i>x.get(start))
            {
                start++;
                if(start==x.size()-k)
                {
                    min=Math.max(min,b-i+1);
                    break;
                }
                end++;
                min=Math.max(x.get(end)-i+1,min);
            }
            //DebugUtils.print(i+" "+min);
        }
        out.println(min);
	}
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}

class IntegerUtils {
    public static boolean [] sieve(int n)
    {
        boolean prime[]=new boolean[n+1];
        Arrays.fill(prime,true);
        prime[0]=false;
        prime[1]=false;
        int sqrt=(int)Math.sqrt(n);
        for(int i=2;i<=sqrt;i++)
            if(prime[i])
                for(int k=i*i;k<=n;k+=i)
                    prime[k]=false;
        return prime;
    }

    }

class DebugUtils {
    public static void print(Object... a)
    {
        boolean oj=System.getProperty("ONLINE_JUDGE")!=null;
        if(!oj)
            System.out.println(Arrays.deepToString(a));
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {

	static public boolean primos[];
	static public int dp[];
	static int sol;

	static public void primos_cal() {
		primos = new boolean[1000001];
		Arrays.fill(primos, true);
		for (int i = 2; i < 1000001; i++) {
			if (!primos[i])
				continue;
			for (int j = 2; (j * i) < 1000001; j++) {
				primos[j * i] = false;
			}
		}
	}

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		primos_cal();
		primos[1] = false;
		dp = new int[1000001];
		for (int i = 1; i < 1000001; i++) {
			dp[i] = dp[i - 1];
			if (primos[i])
				dp[i]++;
		}

		String linea[] = br.readLine().split(" ");
		int a = Integer.parseInt(linea[0]);
		int b = Integer.parseInt(linea[1]);
		int k = Integer.parseInt(linea[2]);

		int I = b - a + 1;
		int rango_a = a - 1;
		int rango_b;
		int solucion = -1;
		boolean flag; int cal;
		sol = 999999;

			  int centro,inf=1,sup=I;

			   while(inf<=sup){
				   //inf<=sup

			     centro=(sup+inf)/2;
			     //System.out.println(centro);
			     int dato = bb(b,centro,k,a);
			     if(dato>=k) sup=centro-1;
			     else
			    	 inf=centro+1;
			   }

		if(sol == 999999){
			sol= -1;
		}
		pr.printf("%d\n", sol);
		pr.close();
	}

	static int bb(int b,int i,int k,int a){

		int rango_b = b - i + 1;
		boolean flag = true;
		int k_max = 0;
		for (int x = a; x <= rango_b; x++) {
			int cal = dp[x + i - 1] - dp[x - 1];
			if (cal < k) {
				flag = false;
			}
			Math.max(cal,k_max);
		}
		if(flag){
			if(i > sol){
				System.out.println(sol);
				System.exit(0);
			}

			sol = Math.min(sol,i);

		}
		return k_max;

	}
}

import java.io.*;

public class CF237C{
  public static void main(String args[]) throws IOException {
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String line = stdin.readLine();
    String[] prms = line.split(" ");
    int a = Integer.parseInt(prms[0]);
    int b = Integer.parseInt(prms[1]);
    int k = Integer.parseInt(prms[2]);

    char[] p = new char[b+1];

    int n = p.length-1;
    p[1]=1;
    for(int i=2; i*i<=n; i++){
      if(p[i] == 0){
        for(int j=i+i; j<=n; j+=i) p[j]=1;
      }
    }
    int cnt = 0;
    int mp = 0;
    for(int i=a; i<=n; i++){
      if(p[i]==0){
        cnt++;
        mp = Math.max(mp, i);
      }
    }
    if(cnt < k) {
      System.out.println(-1);
      return;
    }

    int[] l = new int[cnt];

    int c = 1;
    int d = 0;
    for(int i=a; i<=b; i++){
      if(p[i]==0){
        l[d++]=c;
        c = 1;
      }else{
        c++;
      }
    }

    int len = 0;
    for(int j=0; j<k; j++) len+=l[j];
    int max = len;
    for(int i=1; i<cnt-k; i++){
      len = len - l[i-1] + l[i+k-1];
      max = Math.max(max, len);
    }
    if(len == max) max += (b - mp);
    System.out.println(max);
  }
}

import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Solution {

    static final int[] first10Primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        LinkedList<Integer> primes = primesBetween(a, b);
        primes.addFirst(a - 1);
        primes.addLast(b + 1);
        Iterator<Integer> head = primes.iterator();
        Iterator<Integer> tail = primes.iterator();
        int l = -1;
        for (int i = 0; i < k; i++)
            if (head.hasNext())
                head.next();
            else break;
        while (head.hasNext())
            l = Math.max(l, head.next() - tail.next());
        System.out.println((l <= b - a + 1) ? l : -1);
    }

    static LinkedList<Integer> primesBetween(int a, int b) {

        LinkedList<Integer> tmp = new LinkedList<>();

        for (int i = 9; i >= 0; i--) {
            int p = first10Primes[i];
            if (p > b)
                continue;
            if (p >= a)
                tmp.addFirst(p);
            else break;
        }

        if (b <= 30)
            return tmp;

        // Sieve of Eratosthenes
        int[] sieve = new int[b + 1];
        for (int i = 0; i <= 30; i++)
            sieve[i] = 1;
        for (int p : first10Primes) {
            sieve[p] = 0;
            for (int i = p * p; i <= b; i += p)
                sieve[i] = 1;
        }
        for (int i = 31; i <= b; i++)
            if (sieve[i] == 0) {
                for (int j = i * i; j > 0 && j <= b; j += i)
                    sieve[j] = 1;
                if (i >= a)
                    tmp.addLast(i);
            }

        return tmp;
    }

}

import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a=in.nextInt(),b=in.nextInt(),k=in.nextInt();
        boolean p[]= IntegerUtils.sieve(b+1);
        int c=0,i;
        ArrayList<Integer> x=new ArrayList<Integer>();
        for(i=a;i<=b;i++)
        {
            if(p[i])
            {
                c++;
                x.add(i);
            }
        }
        if(c<k)
        {
            out.println(-1);
            return;
        }
        //DebugUtils.print(c);
        int min=0;
        int start=0,end=k-1;

        min=x.get(k-1)-a+1;
        for(i=a;i<=b;i++)
        {

            if(x.size()-k==start)
            {

                if(p[i])
                min=Math.max(min,b-i+1);
                else min=Math.max(min,b-x.get(start)+1);
                break;
            }

            if(i>x.get(start))
            {
                start++;
                if(start==x.size()-k)
                {
                    min=Math.max(min,b-i+1);
                    break;
                }
                end++;
                min=Math.max(x.get(end)-i+1,min);
            }
            //DebugUtils.print(i+" "+min);
        }
        out.println(min);
	}
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}

class IntegerUtils {
    public static boolean [] sieve(int n)
    {
        boolean prime[]=new boolean[n+1];
        Arrays.fill(prime,true);
        prime[0]=false;
        prime[1]=false;
        int sqrt=(int)Math.sqrt(n);
        for(int i=2;i<=sqrt;i++)
            if(prime[i])
                for(int k=i*i;k<=n;k+=i)
                    prime[k]=false;
        return prime;
    }

    }

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Tolik
 */
public class Codeforces1 {
    public static int[] readIntMas1(){
        Scanner sc = new Scanner(System.in);
        int[] input = new int[sc.nextInt()];
        for (int i = 0; i < input.length; i ++){
            input[i] = sc.nextInt();
        }
        return input;
    }

    public static int[][] readIntMas2(){
        Scanner sc = new Scanner(System.in);
        int[][] input = new int[sc.nextInt()][sc.nextInt()];
        for (int i = 0; i < input.length; i ++){
            for (int j = 0; j < input[j].length; j++){
                input[i][j] = sc.nextInt();
            }
        }
        return input;
    }

    public static int[] readStringToIntWithDigits(){
        Scanner sc = new Scanner(System.in);
        String tmp = sc.nextLine();
        int[] input = new int[tmp.length()];
        for (int i = 0; i < input.length; i++){
            input[i] = Integer.parseInt(String.valueOf(tmp.charAt(i)));
        }
        return input;
    }

    public static int[] readStringToIntWithoutDigits(){
        Scanner sc = new Scanner(System.in);
        String tmp = sc.nextLine();
        int[] input = new int[tmp.length()];
        for (int i = 0; i < input.length; i++){
            if (tmp.charAt(i) == 'a'){
                input[i] = 0;
            } else{
                input[i] = 1;
            }
        }
        return input;
    }

    public static int[][] readStringToIntWithoutDigits2(int n, int m){
        Scanner sc = new Scanner(System.in);
        int[][] input = new int[n][m];
        for (int i = 0; i < n; i++){
            String tmp = sc.nextLine();
            for (int j = 0; j < n; j++){
                if (tmp.charAt(j) == 'a'){
                    input[i][j] = 0;
                } else{
                    input[i][j] = 1;
                }
            }
        }
        return input;
    }

    static int g(int x){
        return x ^ (x >> 1);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 1000001;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        boolean[] ar = new boolean[n];
        for (int i = 0; i < n; i ++){
            ar[i] = true;
        }
        ar[0] = ar[1] = false;
        for (int i=2; i<n; ++i)
    if (ar[i])
        if (((long)i) * i < n)
            for (long j=i*i; j<n; j+=i)
                ar[(int)j] = false;
        int[]ar2 = new int [n];
        ar2[0]  = 0;
        for (int i = 1; i < n; i++){
            if (ar[i]){
                ar2[i] = ar2[i-1] + 1;
            } else{
                ar2[i] = ar2[i-1];
            }
        }
        boolean flag = false;

        for (int l = k; l <= b - a + 1; l++){
            boolean flag2 = true;
            int x = a;
            for (; x <= b - l + 1; x++){
                for (; x>=a && ar2[x+l-1] - ar2[x - 1] < k && (x+l - 1 )< b + 3;l++, x--);
           /*     if (ar2[x+l-1] - ar2[x - 1] < k){
                    flag2 = false;
                    break;
                }*/

            }

                if (l <= b - a + 1  && (ar2[x+l-1] - ar2[x - 1] >= k)){
                    flag = true;
                    System.out.println(l);
                    break;
                }
            }
       if (!flag){
           System.out.println(-1);
       }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class POI {
    static int SIZE = 1100000;
    static ArrayList<Integer> primes = sieve(SIZE);
    static ArrayList<Integer> sieve(int N){
        boolean[] isPrime = new boolean[N + 1];
        ArrayList<Integer> res = new ArrayList<Integer>();
        res.add(0);
        for (int i = 2; i <= N; i++) {
            isPrime[i] = true;
        }
        int i=2;
        for (; i*i <= N; i++) {
            if (isPrime[i]) {
                res.add(i);
                for (int j = i; i*j <= N; j++) {
                    isPrime[i*j] = false;
                }
            }
        }
        for(;i<=N;i++){
            if(isPrime[i])
                res.add(i);
        }
        return res;
    }
    public static void main(String[] args) throws IOException {
        String[] line = new BufferedReader(new InputStreamReader(System.in)).readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int k = Integer.parseInt(line[2]);
        int i=0;
        while(primes.get(i) < a) i++;
        int j=i;
        while(primes.get(j) < b) j++;
        if(j-i < k){
            System.out.println(-1);
            return;
        }
        int l = Math.min(primes.get(i+k)-a,b-primes.get(j-1-k));
        for(;i+k < j;i++){
            l = Math.min(l, primes.get(i+k)-primes.get(i));
        }
        l=Math.min(l, b-a+1);
        System.out.println(l);
        //binarySearch(a,b,k,1,b-a+1);
    }
    private static void binarySearch(int a, int b, int k, int i, int j) {
        while(i<=j){
            int mid = (i+j)>>1;
            if(satisfiable(mid,a,b,k)){
                j = mid-1;
            } else {
                i = mid+1;
            }
        }
    }
    private static boolean satisfiable(int l, int a, int b, int k) {

        return false;
    }
}

import java.util.*;
import java.io.*;
public class C {
	List<Integer> prime;

	public void solve() throws IOException {
		prime = new ArrayList<Integer>();
		prime.add(2);
		int[] sum = new int[1200001];
		sum[2] = 1;
		for(int i = 3; i < sum.length; i++){
			if( i%2 == 0 ){
				sum[i] = sum[i-1];
				continue;
			}
			boolean flag = true;
			for(Integer p : prime){
				if( p > Math.sqrt(i) ){
					prime.add(i);
					break;
				}
				if( i%p == 0 ){
					flag = false;
					break;
				}
			}
			if( flag ){
				sum[i] = sum[i-1]+1;
			} else {
				sum[i] = sum[i-1];
			}
		}

		int a = nextInt();
		int b = nextInt();
		int k = nextInt();
		for(int i = a; i < b; i++){
			if( sum[i]-sum[a-1] >= k ){
				int ans = i-a;
				int id = a+1;
				while( id <= b-ans+1 ){
					if( sum[id+ans-1]-sum[id-1] >= k ){
						id++;
					} else {
						ans++;
					}
				}
				writer.println(ans);
				return;
			}
		}
		writer.println(-1);
	}

	public static void main(String[] args) throws IOException {
		new C().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Codeforces237C {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer init = new StringTokenizer(br.readLine());
		int a = Integer.parseInt(init.nextToken());
		int b = Integer.parseInt(init.nextToken());
		int k = Integer.parseInt(init.nextToken());

		HashMap<Integer,Integer> hmPrime = new HashMap<Integer,Integer>();
		HashMap<Integer,Integer> hmPos = new HashMap<Integer,Integer>();
		int x = 0;
		for (int i = 0; i < b-a+1; i++) {
			if (isPrime(a+i)){
				hmPrime.put(x, i);
				x++;
			}
			hmPos.put(i, x);
		}
		int l = -1;
		if(x==0) {
			System.out.println(-1);
			return;
		}
		if(x-1 == k) {
			System.out.println(b-a+1);
			return;
		}
		if(hmPrime.get(x-k) != null) l = b-a-hmPrime.get(x-k)+1;
		for (int i = 0; i < hmPrime.get(x-1); i++) {
			if(hmPos.get(i) != null && hmPrime.get(hmPos.get(i) + k-1) != null){
				if(hmPrime.get(hmPos.get(i) + k-1)-i > l){
					l = hmPrime.get(hmPos.get(i) + k-1)-i;
				}
			}
		}
		System.out.println(l);
	}

	static boolean isPrime(int n) {
	//check if n is a multiple of 2 or if its 1
		if(n==1) return false;
		if(n==2) return true;
		if(n%2==0) return false;
		    //if not, then just check the odds
	    for(int i=3;i*i<=n;i+=2) {
	        if(n%i==0)
	            return false;
	    }
		return true;
	}
}

import java.util.*;
import java.io.*;

public class Problems {

    private static boolean primes[];

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        /*
        6 13 1
         */
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();

        primes = new boolean[b + 1];

        countPrimes(primes);

        long interval = 0;
        int tempK = 0;
        int end = a;
        int start = a;
        boolean f = false;

        for (int i = a; i <= b; ++i) {
            start = i;

            for (; end <= b; ++end) {
                if (tempK == k) {
                    ++end ;
                    break;
                }
                if (primes[end]) {
                    ++tempK;
                    if (tempK == k) {
                        interval = Math.max(interval, end + 1 - start);
                        ++end ;
                        break;
                    }
                }
                if (end == b) {
                    f = true;
                    break;
                }
            }
            if (f) {
                break;
            }

            if (primes[start]) {
                tempK--;
            }

        }

        if (interval == 0) {
            out.println(-1);
        } else {
            if (f) {
                out.println(end + 2 - start);
            } else {
                out.println(interval);
            }
        }

        out.close();

    }

    public static void countPrimes(boolean primes[]) {
        primes[1] = true ;
        for (int i = 2; i <= primes.length - 1; ++i) {
            boolean s = true;
            for (int x = 2; x * x <= i; ++x) {
                if (i % x == 0) {
                    s = false;
                    break;
                }
            }
            if (s) {
                primes[i] = true;
            }
        }
    }

}

class InputReader {

    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a=in.nextInt(),b=in.nextInt(),k=in.nextInt();
        boolean p[]= IntegerUtils.sieve(b+1);
        int c=0,i;
        ArrayList<Integer> x=new ArrayList<Integer>();
        for(i=a;i<=b;i++)
        {
            if(p[i])
            {
                c++;
                x.add(i);
            }
        }
        if(c<k)
        {
            out.println(-1);
            return;
        }
        DebugUtils.print(c);
        int min=0;
        int start=0,end=k-1;
        for(i=a;i<=b;i++)
        {

            if(start==x.size()-k)
                            {
                                min=Math.max(min,b-x.get(start)+1);
                                continue;
                            }
            if(i>x.get(start))
            {
                start++;
                if(start==x.size()-k)
                {
                    min=Math.max(min,b-i+1);
                    break;
                }
                end++;
                min=Math.max(x.get(end)-i+1,min);
            }
            //DebugUtils.print(i+" "+min);
        }
        out.println(min);
	}
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}

class IntegerUtils {
    public static boolean [] sieve(int n)
    {
        boolean prime[]=new boolean[n+1];
        Arrays.fill(prime,true);
        prime[0]=false;
        prime[1]=false;
        int sqrt=(int)Math.sqrt(n);
        for(int i=2;i<=sqrt;i++)
            if(prime[i])
                for(int k=i*i;k<=n;k+=i)
                    prime[k]=false;
        return prime;
    }

    }

class DebugUtils {
    public static void print(Object... a)
    {
        boolean oj=System.getProperty("ONLINE_JUDGE")!=null;
        if(!oj)
            System.out.println(Arrays.deepToString(a));
    }
}

import java.util.Scanner;

public class bearandpoker {

	public static int gcd(int m, int n) {
		if(n == 0) {
			return m;
		}
		return gcd(n, m%n);
	}

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int [] bets = new int[n];
		for(int i = 0; i < n; i++) {
			bets[i] = scan.nextInt();
		}
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				int gcd = gcd(bets[i], bets[j]);
				int xdiff = bets[i] / gcd;
				while(xdiff % 2 == 0) {
					xdiff /= 2;
				}
				while (xdiff % 3 == 0) {
					xdiff /= 3;
				}
				if(xdiff != 1) {
					System.out.println("No");
					System.out.println(xdiff);
					System.out.println(bets[i]);
					System.out.println(bets[j]);
					System.out.println(gcd);
					return;
				}
				int ydiff = bets[j] / gcd;
				while(ydiff % 2 == 0) {
					ydiff /= 2;
				}
				while (ydiff % 3 == 0) {
					ydiff /= 3;
				}
				if(ydiff != 1) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class PrimesInterval {

	Scanner in;
	PrintWriter out;

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		new PrimesInterval().run();

	}

	private void solve(){
		int a = in.nextInt();
		int b = in.nextInt();
		int k = in.nextInt();

		int[] p = new int[b + 1];
		p[1] = 1;
		for (int i = 2; i <= b; i ++) if (p[i] == 0){
			for (int j = 2*i; j <= b; j += i){
				p[j] = 1;
			}
		}

		int cnt = 0;
		int i;
		for (i = a; i <= b; i ++){
			if (p[i] == 0) {
				cnt ++;
				if (cnt == k) break;
			}
		}

		if (cnt < k){
			out.println(-1);
			return;
		}

		int l = i - a + 1;
		i = a;
		while (i + l - 1 < b){
			if (p[i] == 0 && p[i + l] == 1){
				l ++;
			}
			else i ++;
		}
		out.println(l);
	}

	void run() throws IOException {
		in = new Scanner(System.in);
        out = new PrintWriter(System.out);

		solve();

		in.close();
		out.close();
	}
}

import java.util.ArrayList;
import java.util.Scanner;

public class Solution {

	public void solve(){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		boolean[] isPrime = new boolean[b+1];

		for(int i = 2; i <= b; i++){
			isPrime[i] = true;
		}

		for(int i = 2; i <= b; i++){
			if(isPrime[i]){
				for(int j = i+i; j <= b; j+=i){
					isPrime[j] = false;
				}
			}
		}

//		for(int i = 2; i <= b; i++){
//			System.out.println(i + ": " + isPrime[i]);
//		}

		ArrayList<Integer> primeList = new ArrayList<Integer>();
		for(int i = a; i <= b; i++){
			if( isPrime[i]){
				primeList.add(i);
			}
		}

		if(primeList.size() < k){
			System.out.println("-1");
			return;
		}

//		for(int i = 0; i < primeList.size(); i++){
//
//		}

		int maxDist = Integer.MIN_VALUE;
		for(int i = k-1; i < primeList.size(); i++){
			int d = 0;
			if( i == k-1){
				//System.out.println( "A" + primeList.get(i) + ", " + a);
				d += (primeList.get(i) - a)+1;
			}
			if( i == primeList.size() - 1){
				//System.out.println( "B" + b + ", " + primeList.get(i));
				d += b - primeList.get(i);
			}

			if( i != k-1 && i != primeList.size()-1){
				//System.out.println( "C" + primeList.get(i) + ", " + primeList.get(i-k));
				d = primeList.get(i) - primeList.get(i-k);
			}

			if(d > maxDist) maxDist = d;
		}

		System.out.println( maxDist );

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Solution().solve();
	}

}