from sys import stdin
import fractions, time, math, random

def line():
    return stdin.readline().split()
def read_int():
    return int(line()[0])
def read_ints():
    return [int(x) for x in line()]
def memo(fn):
    table = {}
    def memoized(*args):
        if args not in table:
            table[args] = fn(*args)
        return table[args]
    return memoized

def solve(a, b, k):
    possible_prime = [False] * 2 + [True] * (10**6)
    for x in range(2, 10**6 + 1):
        if possible_prime[x]:
            for multiple in range(2*x, 10**6 + 1, x):
                possible_prime[multiple] = False
        else: continue
    primes = [x for x in range(10**6 + 1) if possible_prime[x]]

    primes = [x for x in primes if x >= a and x <= b]
    if len(primes) < k:
        return -1

    l = primes[k - 1] - a + 1
    for p_i in range(len(primes) - k):
        prime1 = primes[p_i]
        prime2 = primes[p_i + k]
        l = max(l, prime2 - prime1)
    l = max(l, b - primes[len(primes) - k] + 1)
    return l

a, b, k = read_ints()
print solve(a, b, k)

def main():
    def sieve(n):
        s = xrange(3, n + 1, 2)
        r = set(s)
        [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]
        return r.union([2])
    a,b,k=map(int,raw_input().split())
    p=filter(lambda x:x>=a and x<=b,sorted(sieve(b)))
    if len(p)<k:
        print -1
        return
    #print p
    m=max(p[k-1]-a+1,b-p[-k]+1)
    try:
        print max(m,max([p[i+k]-p[i] for i in range(len(p)-k)]))
    except:
        print m

if __name__ == '__main__':
    main()

DEBUG = False

a, b, k = [int(x) for x in raw_input().split()]
MAXN = b + 100
isprime = [True] * MAXN
isprime[0] = isprime[1] = False
for i in xrange(2, MAXN):
    if isprime[i]:
        for j in xrange(i + i, MAXN, i):
            isprime[j] = False
p = q = a
count = 0
while q <= b:
    if count < k:
        count += isprime[q]
        q += 1
        if DEBUG:
            print 'Right', p, q, count
    else:
        count -= isprime[p]
        p += 1
        count += isprime[q]
        q += 1
        if DEBUG:
            print 'Together', p, q, count

temp = b
count = 0
while count < k and temp >= a:
    if isprime[temp]:
        count += 1
    temp -= 1

print max(q - p, b - temp) if count == k else -1

a,b,k=map(int,raw_input().split())
t,p=[True]*(b+1),[]
for i in range(2,b+1):
    if t[i]:
        if i>=a:p.append(i)
        for j in range(i * i, b + 1, i):t[j] = False
print -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])

a,b,k=map(int,raw_input().split())
def sieveoferatosthenes(n):
    lst=[]
    prime = [True for i in range(n+1)]
    p=2
    while(p * p <= n):

        if (prime[p] == True):

            for i in range(p * 2, n+1, p):
                prime[i] = False
        p+=1
    lis =[]

    for p in range(2, n):
        if prime[p]:
            lst.append(p)
    return lst
from bisect import *
lst=sieveoferatosthenes(1000002)
l=0
h=10**6+2
l1=[]
l2=[]
for i in range(0,1000000):
   l1.append(bisect_left(lst,i))
for i in range(0,1500000):
   l2.append(bisect(lst,i))
for i in range(1,22):
    m=(l+h)/2
    c=0
    for x in range(a,b-m+2):
        sv=x
        ev=x+m-1
      #  print sv,ev,m
      #  ix1=bisect_left(lst,sv)
      #  ix2=bisect(lst,ev)
        ix1=l1[sv]
        ix2=l2[ev]
      #  print ix2,ix1
        if ix2-ix1<k:
            c=-1
    if c==-1:
        l=m
    else:
        h=m
ans=m
def check(i):
    m=i
    c=0
    for x in range(a,b-m+2):
        sv=x
        ev=x+m-1
        #print sv,ev,m
        ix1=l1[sv]
        ix2=l2[ev]
        #print ix2,ix1
        if ix2-ix1<k:
            c=-1
            break
    if c==-1:
        return 0
    else:
        return 1
if check(m) and m<=b-a+1:
    print m
elif check(m+1) and m<=b-a:
    print m+1
else:
    print -1

import sys

a, b, k = map(int, sys.stdin.readline().split())

def sieve(n):
    primes = [True] * (n + 1)
    primes[0] = primes[1] = False
    for i in range(1, n + 1):
        if primes[i]:
            for j in xrange(i + i, n + 1, i):
                primes[j] = False
    return primes

def verify(a, b, k, l, primes):
    numOnes = 0
    for i in range(a, a + l):
        if primes[i]:
            numOnes += 1

    lo = a
    hi = a + l - 1
    for i in range(a, b - l + 2):
        if numOnes < k:
            return False
        if primes[lo]:
            numOnes -= 1
        lo += 1
        hi += 1
        if primes[hi]:
            numOnes += 1

    return True

primes = sieve(b * 2)

lo = 1
hi = b - a + 2
while(lo < hi):
    mid = (lo + hi) // 2
    if verify(a, b, k, mid, primes):
        hi = mid
    else:
        lo = mid + 1

if lo != b - a + 2:
    print lo
else:
    print -1

import math
from collections import deque
def p(mid, arr, k):
	counter = 0
	#d = deque()
	totalSum = 0
	#sliding window
	#print (arr)
	size = 0
	for i in range(a, b+1):
		size += 1
		#d.append(arr[i])

		totalSum += arr[i]
		takeAway = 0
		if size > mid:
			takeAway = arr[i - mid]

		totalSum -= takeAway

		if size >= mid:
			if totalSum < k:
				return False

	if totalSum < k:
		return False
	return True

splitted = raw_input().split(" ")
a = int(splitted[0])
b = int(splitted[1])
k = int(splitted[2])

#generate primes up to b, using sieve
sieve = [True] * (b + 1)
primes = deque()
for i in range(2, b + 1):
	#print (i)
	if sieve[i]:
		primes.append(i)
	else:
		continue
	j = 2 * i
	while j < b + 1:
		sieve[j] = False
		j += i

arr = [0] * (b + 1)
for prime in primes:
	arr[prime] = 1
#print (primes)
#print (arr)
counter = 0
savedI = -1
low = 1
high = b - a + 1
while low + 1 < high:
	mid = low + (high - low)/2
	#print (str(low) + ", " + str(high))
	if p(mid, arr, k) == True:
		high = mid
		#print (str(mid) + " returned true")
	else:
		low = mid
		#print (str(mid) + " returned false")
if p(high, arr, k) == True:
	print (high)
else:
	print (-1)

# Author : raj1307 - Raj Singh
# Date   : 20.04.2020

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1]
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(n-r))

def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

prime = [True for i in range(10000005)]
x=[]
def SieveOfEratosthenes(n):

    # Create a boolean array "prime[0..n]" and initialize
    #  all entries it as true. A value in prime[i] will
    # finally be false if i is Not a prime, else true.
    p = 2
    while (p * p <= n):

        # If prime[p] is not changed, then it is a prime
        if (prime[p] == True):

            # Update all multiples of p
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1

    # Print all prime numbers
    for p in range(2, n):
        if prime[p]:
            x.append(p)

def main():

    #for _ in range(ii()):

    a,b,k=mi()
    SieveOfEratosthenes(1000000)
    prime[1]=False
    f=[]
    f.append(0)
    for i in range(a,b+1):
        if prime[i]:
            f.append(1)
        else:
            f.append(0)

    le=b-a+1

    for i in range(1,le+1):
        f[i]+=f[i-1]

    l=0
    r=le
    ans=-1
    while l<=r:
        mid=(l+r)//2
        flag=1

        for i in range(1,le+1):

            if i+mid-1>le:
                break

            if f[i+mid-1]-f[i-1]<k:
                flag=0
                break

        if flag:
            ans=mid
            r=mid-1
        else:
            l=mid+1

    print(ans)

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

MAX=10**6+1
dp=[0]*(MAX+10)
prime=[1 for i in range(MAX+1)]
p=2
while p*p<=MAX:
	if prime[p]==1:
		for i in range(p*2,MAX+1,p):
			prime[i]=0
	p+=1
prime[0]=0
prime[1]=0
for i in range(1,MAX):
	dp[i]=dp[i-1]+prime[i]
a,b,k=map(int,raw_input().split())
if dp[b]-dp[a-1]<k:
	print -1
else:
	low=1
	high=b-a+1
	while low<high:
		flag=False
		mid=low+(high-low)/2
		for i in range(a,b):
			if i+mid-1>b:
				break
			if dp[i+mid-1]-dp[i-1]<k:
				flag=True
				break
		if flag:
			low=mid+1
		else:
			high=mid
	print low

import sys
from math import gcd,sqrt,ceil
from collections import defaultdict,Counter,deque
from bisect import bisect_left,bisect_right
import math

# input=sys.stdin.readline
# def print(x):
#     sys.stdout.write(str(x)+"\n")

# sys.stdout=open("CP1/output.txt",'w')
# sys.stdin=open("CP1/input.txt",'r')
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# import sys
# import io, os
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def get_sum(bit,i):
    s = 0

    i+=1
    while i>0:
        s+=bit[i]
        i-=i&(-i)

    return s

def update(bit,n,i,v):
    i+=1

    while i<=n:
        bit[i]+=v
        i+=i&(-i)

def modInverse(b,m):
    g = math.gcd(b, m)
    if (g != 1):
        return -1
    else:
        return pow(b, m - 2, m)

def primeFactors(n):

    sa = set()
    sa.add(n)
    while n % 2 == 0:
        sa.add(2)
        n = n // 2

    for i in range(3,int(math.sqrt(n))+1,2):

        while n % i== 0:
            sa.add(i)
            n = n // i

    # sa.add(n)
    return sa

def seive(n):

    pri = [True]*(n+1)
    p = 2
    while p*p<=n:

        if pri[p] == True:

            for i in range(p*p,n+1,p):
                pri[i] = False

        p+=1

    return pri

def ifposs(l):

    i = a
    # print(l)
    while b-i+1>=l:

        z = i+l-1

        if pre[z]-pre[i-1]<k:
            return False

        else:
            i+=1

    return True

a,b,k = map(int,input().split())

pri = []
h = seive(b+1)
h[1] = False
pre = [0]
for i in range(a,b+1):
    if h[i] == True:

        pri.append(i)
        pre.append(pre[-1]+1)
    else:
        pre.append(pre[-1])

pre = [0]*(a-1) + pre
# print(pre)
# print(pri)
if len(pri)<k:
    print(-1)
else:
    i = j = a
    l = 0

    while j<=b:

        if pre[j]-pre[i-1]<k:
            j+=1

        else:
            l = max(l,j-i+1)
            i+=1
    l = max(l,j-i+1)
    print(l)

from sys import stdin

def main():
    a, b, k = map(int, stdin.readline().split())
    check = [True] * (10 ** 6 + 1)
    check[1] = False
    check[0] = False
    index = 2
    bound = 10 ** 6
    while index * index <= bound:
        if check[index]:
            for i in range(index * index, bound + 1, index):
                check[i] = False
        index += 1
    dp = [0] * (bound + 1)
    for i in range(2, bound + 1):
        if check[i]:
            dp[i] = dp[i - 1] + 1
        else:
            dp[i] = dp[i - 1]
    low = 0
    high = (b - a) + 2
    while low < high:
        mid = (low + high) >> 1
        ok = True
        for i in range(a, b - mid + 2):
            if dp[i + mid - 1] - dp[i - 1] < k:
                ok = False
                break
        if ok:
            high = mid
        else:
            low = mid + 1
    print(low if low <= (b - a + 1) else - 1)

if __name__ == "__main__":
    main()

from math import floor, sqrt

def siv(limit, primes):
    mark = [False] * (limit + 1)
    for i in range(2, limit + 1):
        if not mark[i]:
            primes.append(i)
            for j in range(i, limit + 1, i):
                mark[j] = True

def pir(low, high, prims):
    limit = floor(sqrt(high)) + 1
    primes = list()
    siv(limit, primes)
    n = high - low + 1
    mark = [False] * (n + 1)
    for i in range(len(primes)):
        loLim = floor(low / primes[i]) * primes[i]
        if loLim < low:
            loLim += primes[i]
        if loLim == primes[i]:
            loLim += primes[i]
        for j in range(loLim, high + 1, primes[i]):
            mark[j - low] = True
    pc = 0
    for i in range(low, high + 1):
        if not mark[i - low]:
            prims.append(i)
            pc += 1
    return pc

a, b, k = [int(i) for i in input().split()]

prims = []
pc = pir(a, b, prims)
if pc!= 0 and prims[0] == 1:
    prims.remove(1)
    pc-=1

if pc < k:
    print(-1)
    exit()

mx = max(prims[k - 1] - a + 1, b - prims[len(prims) - k] + 1)

for i in range(len(prims) - k):
    mx = max(prims[i + k] - prims[i], mx)

print(mx)

N = int(1e6+3)
is_prime = [0] * N

def primes():
    for i in range(2, N):
        if is_prime[i] == 1:
            continue
        for j in range(2*i, N, i):
            is_prime[j] = 1

a, b, k = map(int, input().split())
primes()
cnt_primes = [0] * N
for i in range(2, N):
    cnt_primes[i] = cnt_primes[i-1] + (1 - is_prime[i])

def valid(x):
    for i in range(a, b-x+2):
        if cnt_primes[i+x-1] - cnt_primes[i-1] < k:
            return False
    return True

def binary_search():
    f, e = 1, b-a+1
    while e >= f:
        m = f+e >> 1
        if valid(m):
            e = m - 1
        else:
            f = m + 1
    return f

res = binary_search()
print(res if valid(res) and res <= b-a+1 else -1)

import sys, os.path
from collections import*
from copy import*
import math
mod=10**9+7
if(os.path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")

N = int(1e6+5)
is_prime = [0] * N

def primes():
    for i in range(2, N):
        if is_prime[i] == 1:
            continue
        for j in range(2*i, N, i):
            is_prime[j] = 1

a, b, k = map(int, input().split())
primes()
cnt_primes = [0] * N
for i in range(2, N):
    cnt_primes[i] = cnt_primes[i-1] + (1 - is_prime[i])

def valid(x):
    for i in range(a, b-x+2):
        if cnt_primes[i+x-1] - cnt_primes[i-1] < k:
            return False
    return True

def binary_search():
    f, e = 1, b-a+1
    best=-1
    while f<=e:
        m = f+(e-f)//2
        if valid(m):
            best=m
            e = m - 1
        else:
            f = m + 1
    return best

res = binary_search()
print(res)

import sys
from collections import deque
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())

def read():
    zz=0
    if zz:
        input=sys.stdin.readline
    else:
        sys.stdin=open('input1.txt', 'r')
        sys.stdout=open('output1.txt','w')

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def solve():

    n=1000005
    sieve=[1]*1000005
    sieve[0],sieve[1]=0,0
    for i in range(2,int(sqrt(n))):
        if(sieve[i]):
            for j in range(i*i,n,i):
                sieve[j]=0
    for i in range(1,n):
        sieve[i]+=sieve[i-1]

    def check(m):
        for i in range(a,b-m+2):
            x=sieve[i+m-1]-sieve[i-1]
            if(x<k):
                return 0
        return 1

    def bs(r):
        l=1
        ans=-1
        while(l<=r):
            m=l+(r-l)//2
            if(check(m)):
                ans=m
                r=m-1
            else:
                l=m+1
        return ans

    # print(sieve)
    global a,b,k
    a,b,k=mi()
    ans=bs(b-a+1)
    print(ans)

if __name__== "__main__":
    # read()
    solve()

'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:07/05/2020

'''
from collections import deque
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def solve():

    n=1000005
    sieve=[1]*1000005
    sieve[0],sieve[1]=0,0
    for i in range(2,int(sqrt(n))):
        if(sieve[i]):
            for j in range(i*i,n,i):
                sieve[j]=0
    for i in range(1,n):
        sieve[i]+=sieve[i-1]

    def check(m):
        for i in range(a,b-m+2):
            x=sieve[i+m-1]-sieve[i-1]
            if(x<k):
                return 0
        return 1

    def bs(r):
        l=1
        ans=-1
        while(l<=r):
            m=l+(r-l)//2
            if(check(m)):
                ans=m
                r=m-1
            else:
                l=m+1
        return ans

    # print(sieve)
    global a,b,k
    a,b,k=mi()
    ans=bs(b-a+1)
    print(ans)

if __name__== "__main__":
    solve()

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

a,b,k = mints()

p = [True]*(b+1)
for i in range(2, b+1):
	if p[i]:
		for j in range(i*i, b+1, i):
			p[j] = False

p[1] = False
#d = []
#for i in range(a, b+1)
#	if p[i]:
#		d.append(i)
c = 0
i = a
q = [0]*(b+1)
ql = 1
qr = 1
q[0] = a-1
while c < k and i <= b:
	if p[i]:
		c += 1
		q[qr] = i
		qr += 1
	i += 1
if c != k:
	print(-1)
	exit(0)
#print(q[qr-1],a)
r = q[qr-1]-a
while i <= b:
	#print(r, q[qr-1],q[ql-1]+1)
	r = max(r, q[qr-1]-(q[ql-1]+1))
	ql += 1
	c -= 1
	while i <= b:
		if p[i]:
			q[qr] = i
			qr += 1
			c += 1
			i += 1
			break
		i += 1
if c == k:
	#print(r, b, q[ql-1]+1)
	r = max(r, b-q[ql-1]-1)
else:
	#print(r, b, q[ql-1])
	r = max(r, b-q[ql-1])
print(r+1)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
#prime = {}
a , b , k  =I()
visited[1] = True
li = []
for i in range(2,int(b**(0.5))+1) :
    #print(visited[:14])
    if visited[i] == False :
        #prime[i] = 1
        for j in range (i+i,b+1 , i) :
            visited[j] =True
for i in range (a,b+1)   :
    if visited[i] == False :
        li.append(i)
ans = 0
maxx = 0
#print(li)
t1 = a
#print(li)
if len(li) < k :
    exit(print("-1"))
n = len(li)
for i in range (n-k+1) :
    ans = li[i+k-1] -t1 + 1
    #print(ans)
    maxx = max(maxx,ans)
    t1 = li[i] + 1
ww = b - li[-k] + 1
#print(ww)
maxx = max(ww,maxx)
print(maxx)

def f(n):
    m = int(n ** 0.5) + 1
    t = [1] * (n + 1)
    for i in range(3, m):
        if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
    return [2] + [i for i in range(3, n + 1, 2) if t[i]]

a, b, k = map(int, input().split())
n = 2000001

t, p, x = [-1] * n, f(n), -1
k -= 1; b += 1

for i in range(len(p) - k):
    t[p[i]] = p[i + k] - p[i]

t.reverse()
for i in range(1, n):
    if t[i] < 0: t[i] = t[i - 1] + 1
t.reverse()

for i in range(a + 1, b):
    t[i] = max(t[i], t[i - 1])

for l in range(1, b - a + 1):
    if t[b - l] < l:
        x = l
        break
print(x)

def f(n):
    m, l = int(n ** 0.5) + 1, n - 1
    t = [1] * n
    for i in range(3, m):
        if t[i]: t[i * i :: 2 * i] = [0] * ((l - i * i) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if t[i]]

a, b, k = map(int, input().split())
k -= 1; b += 1; n = b + 100

t, p, x = [-1] * n, f(n), -1

for i in range(len(p) - k):
    t[p[i]] = p[i + k] - p[i]

t.reverse()
for i in range(1, n):
    if t[i] < 0: t[i] = t[i - 1] + 1
t.reverse()

if len(p) > k:
    for i in range(a + 1, b):
        t[i] = max(t[i], t[i - 1])

    for l in range(1, b - a + 1):
        if t[b - l] < l:
            x = l
            break
print(x)

def f(a, b):

    t = [1] * (b + 1)

    for i in range(3, int(b ** 0.5) + 1):

        if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)

    return [i for i in range(3, b + 1, 2) if t[i] and i > a]

a, b, k = map(int, input().split())

p = f(a - 1, b)

if 3 > a and b > 1: p = [2] + p

if k > len(p): print(-1)

elif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))

else: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))

# Made By Mostafa_Khaled

def main():
    def f(n):
        m = int(n ** 0.5) + 1
        t = [1] * (n + 1)
        for i in range(3, m):
            if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
        return [2] + [i for i in range(3, n + 1, 2) if t[i]]

    a, b, k = map(int, input().split())
    n = 1100001

    t, p, x = [-1] * n, f(n), -1
    k -= 1; b += 1

    for i in range(len(p) - k):
        t[p[i]] = p[i + k] - p[i]
    for i in range(1,n):
        if t[-i] < 0:
            t[-i] = t[-i + 1] + 1
    for i in range(a + 1, b):
        t[i] = max(t[i], t[i - 1])
    for l in range(1, b - a + 1):
        if t[b - l] < l:
            x = l
            break
    print(x)
main()

# ~*~ coding:utf-8 ~*-
from bisect import bisect_left

a, b, k = map(int, raw_input().split())

nums = [True] * (10 ** 6 + 1)

nums[0] = False
nums[1] = False

for i in xrange(2, 10 ** 3 + 1):
    if not nums[i]:
        continue
    for j in xrange(i + i, 10 ** 6 + 1, i):
        nums[j] = False

primes = [i for i, e in enumerate(nums) if e]
pct = len(primes)

if b == 1:
    print -1
    exit()

p = bisect_left(primes, a)
if p + k - 1 >= pct:
    print -1
    exit()
else:
    req = primes[p + k - 1] - a + 1
rest = b - a + 1

if rest < req:
    print -1
    exit()

for i in xrange(a, b + 1):
    if rest < req:
        print rest + 1
        break
    if i == primes[p]:
        p += 1
        if p + k - 1 >= pct:
            print rest
            exit()
        else:
            req = max(req, primes[p + k - 1] - (primes[p - 1] + 1) + 1)
    rest -= 1
else:
    print 1

r = raw_input().split()
a = int(r[0])
b = int(r[1])
k = int(r[2])
c = []
d = []
for x in range(b+1):
    c.append(1)
c[1] = 1
for x in range(2,b+1):
    if c[x] == 1:
        #print x
        if a <= x <= b:
            d.append(x)
        for y in range(2, b//x+1):
            c[y*x] = 0
#d.append(b)
if len(d) >= k:
    j = d[k-1]
    l = d[-k]
for x in range(1,len(d)-k+1):
    d[len(d)-x] -= d[len(d)-x-k]
if len(d) == k:
    print str(max(b - d[0] + 1, d[len(d)-1] - a + 1))
elif len(d) < k:
    print -1
else:
    for x in range(0, k):
        d[x] = 0
    #print d, a, b
    g = max(d)
    g = max(g, j  - a + 1, b - l + 1)
    print g

from bisect import *
def main():
    p = [0] * 2 + [1] * (10 ** 6 + 10)
    x = []
    for i in xrange(2, 10 ** 6 + 10):
        if p[i]:
            x.append(i)
            for j in xrange(i+i, 10 ** 6 + 10, i):
                p[j] = 0
    a, b, k = map(int, raw_input().split())
    cnt = 0
    i = a
    while i <= b:
        if p[i]: cnt += 1
        if cnt == k: break
        i += 1
    if cnt < k:
        print -1
        return
    ans = i - a + 1
    s = bisect_left(x, a)
    while s+k < len(x) and x[s+k] <= b:
        #print s, x[s], x[s+k]
        ans = max(x[s+k] - x[s], ans)
        s += 1
    cnt = 0
    i = b
    while i >= a:
        if p[i]: cnt += 1
        if cnt == k: break
        i -= 1
    ans = max(b - i + 1, ans)
    """s = bisect_left(x, b + 1) - 1
    while s >= k and x[s-k] >= a:
        print s, x[s], x[s-k]
        ans = max(x[s] - x[s-k], ans)
        s -= 1"""
    print ans
main()

def sieve(n):
    s = xrange(3, n + 1, 2)
    r = set(s)
    [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]
    return r.union([2])
a,b,k=map(int,raw_input().split())
p=filter(lambda x:x>=a and x<=b,sorted(sieve(b)))
if len(p)<k:
    print -1
    exit()
#print p
m=max(p[k-1]-a+1,b-p[-k]+1)
try:
    print max(m,max([p[i+k]-p[i] for i in range(len(p)-k)]))
except:
    print m

a,b,k=map(int,raw_input().split())
p=[]
t=[1]*(b+1)
for i in xrange(2,b+1):
    if t[i]:
        if i >= a:
            p.append(i)
        for j in range(i*i, b+1, i):
            t[j]=0
if len(p) < k:
    print -1
else:
    m=[p[i]-p[i-k] for i in range(k, len(p))]+[p[k-1]-a+1,b-p[-k]+1]

    print max(m)

a, b, k = map(int, raw_input().split())
t, p = [True] * (b + 1), []
for i in range(2, b + 1):
	if t[i]:
		if i >= a:
			p.append(i)
		for j in range(i * i, b + 1, i):
			t[j] = False
print -1 if len(p) < k else max([p[i] - p[i - k] for i in range(k, len(p))] + [b - p[-k] + 1, p[k - 1] - a + 1])

def sv(a, b):
    t = [1] * (b + 1)
    for i in range(3, int(b ** 0.5) + 1):
        if t[i]:
            for j in range(i*i,b+1,i):
                t[j] = 0
    return [i for i in range(3,b+1,2) if t[i] and i>a]
a, b, k = map(int, raw_input().split())
p = sv(a - 1, b)
if 3 > a and b > 1: p = [2] + p
if k > len(p):
    print(-1)
elif len(p) == k:
    print(max(p[k - 1] - a + 1, b - p[0] + 1))
else:
    print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))

##http://codeforces.ru/problemset/problem/237/C
import time

def eratosfen_interval(a, b ,k, toprint):
    l = [True]*(b+1)
    i = 2
    primelist = []
    while i <= len(l):
        try:
            i = l.index(True, i)
            if a <= i <= b:
                primelist.append(i)
        except ValueError:
            i = len(l) +1
        for j in xrange(2*i, len(l), i):
            l[j] = False
        i+=1
    del(l)

    if k > len(primelist): return -1
    interval = max(primelist[k-1] - a + 1, b - primelist[-k]+1)

    if toprint: print primelist
    if toprint: print 'interval', interval

    for i in xrange(0, len(primelist)-k, 1):
        if toprint: print 'i', i
        if toprint: print 'interval', interval
        if toprint: print 'dif', primelist[i+k] - primelist[i]
        interval = max(interval, primelist[i+k] - primelist[i])
    return interval

a, b ,k = map(int, raw_input().split())

print eratosfen_interval(a, b ,k, toprint = False)

def f(a, b):
    t = [1] * (b + 1)
    for i in range(3, int(b ** 0.5) + 1):
        if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)
    return [i for i in range(3, b + 1, 2) if t[i] and i > a]

a, b, k = map(int, raw_input().split())

p = f(a - 1, b)
if 3 > a and b > 1: p = [2] + p

if k > len(p): print(-1)
elif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))
else: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

a,b,k = mints()

p = [True]*(b+1)
for i in range(2, b+1):
	if p[i]:
		for j in range(i*i, b+1, i):
			p[j] = False

p[1] = False
#d = []
#for i in range(a, b+1)
#	if p[i]:
#		d.append(i)
c = 0
i = a
q = [0]*(b+1)
ql = 1
qr = 1
q[0] = a-1
while c < k and i <= b:
	if p[i]:
		c += 1
		q[qr] = i
		qr += 1
	i += 1
if c != k:
	print(-1)
	exit(0)
r = q[qr-1]-a
while i < b:
	#print(r, q[qr-1],q[ql-1]+1)
	r = max(r, q[qr-1]-(q[ql-1]+1))
	ql += 1
	c -= 1
	while i < b:
		if p[i]:
			q[qr] = i
			qr += 1
			c += 1
			i += 1
			break
		i += 1
if c == k:
	r = max(r, b-q[1])
else:
	#print(r, b, q[ql-1]+1)
	r = max(r, b-q[ql-1])
print(r+1)

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

a,b,k = mints()

p = [True]*(b+1)
for i in range(2, b+1):
	if p[i]:
		for j in range(i*i, b+1, i):
			p[j] = False

p[1] = False
#d = []
#for i in range(a, b+1)
#	if p[i]:
#		d.append(i)
c = 0
i = a
q = [0]*(b+1)
ql = 1
qr = 1
q[0] = a-1
while c < k and i <= b:
	if p[i]:
		c += 1
		q[qr] = i
		qr += 1
	i += 1
if c != k:
	print(-1)
	exit(0)
#print(q[qr-1],a)
r = q[qr-1]-a
while i <= b:
	#print(r, q[qr-1],q[ql-1]+1)
	r = max(r, q[qr-1]-(q[ql-1]+1))
	ql += 1
	c -= 1
	while i <= b:
		if p[i]:
			q[qr] = i
			qr += 1
			c += 1
			i += 1
			break
		i += 1
if c == k:
	#print(r, b, q[ql])
	r = max(r, b-q[ql])
else:
	#print(r, b, q[ql-1])
	r = max(r, b-q[ql-1])
print(r+1)

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

a,b,k = mints()

p = [True]*(b+1)
for i in range(2, b+1):
	if p[i]:
		for j in range(i*i, b+1, i):
			p[j] = False

p[1] = False
c = 0
i = a
q = [0]*(b+1)
ql = 0
qr = 0
while c < k and i <= b:
	if p[i]:
		c += 1
		q[qr] = i
		qr += 1
	i += 1
if c != k:
	print(-1)
	exit(0)
print(q[qr-1],a)
r = q[qr-1]-a
while i < b:
	print(q[qr-1],q[ql])
	r = max(r, q[qr-1], q[ql])
	ql += 1
	c -= 1
	while i < b:
		if p[i]:
			q[qr] = i
			qr += 1
			c += 1
			i += 1
			break
		i += 1
if c == k:
	print(b, q[ql])
	r = max(r, b-q[ql])
else:
	print(b, q[ql-1])
	r = max(r, b-q[ql-1])
print(r+1)

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

a,b,k = mints()

p = [True]*(b+1)
for i in range(2, b+1):
	if p[i]:
		for j in range(i*i, b+1, i):
			p[j] = False

p[1] = False
#d = []
#for i in range(a, b+1)
#	if p[i]:
#		d.append(i)
c = 0
i = a
q = [0]*(b+1)
ql = 1
qr = 1
q[0] = a-1
while c < k and i <= b:
	if p[i]:
		c += 1
		q[qr] = i
		qr += 1
	i += 1
if c != k:
	print(-1)
	exit(0)
r = q[qr-1]-a
while i < b:
	#print(r, q[qr-1],q[ql-1]+1)
	r = max(r, q[qr-1]-q[ql-1]-1)
	ql += 1
	c -= 1
	while i < b:
		if p[i]:
			q[qr] = i
			qr += 1
			c += 1
			i += 1
			break
		i += 1
if c == k:
	r = max(r, b-q[1])
else:
	#print(r, b, q[ql-1]+1)
	r = max(r, b-q[ql-1]+1)
print(r+1)

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

a,b,k = mints()

p = [True]*(b+1)
for i in range(2, b+1):
	if p[i]:
		for j in range(i*i, b+1, i):
			p[j] = False

p[1] = False
c = 0
i = a
q = [0]*(b+1)
ql = 0
qr = 0
while c < k and i <= b:
	if p[i]:
		c += 1
		q[qr] = i
		qr += 1
	i += 1
if c != k:
	print(-1)
	exit(0)
#print(q[qr-1],a)
r = q[qr-1]-a
while i < b:
	#print(q[qr-1],q[ql])
	r = max(r, q[qr-1], q[ql])
	ql += 1
	c -= 1
	while i < b:
		if p[i]:
			q[qr] = i
			qr += 1
			c += 1
			i += 1
			break
		i += 1
if c == k:
	#print(b, q[ql])
	r = max(r, b-q[ql])
else:
	#print(b, q[ql-1])
	r = max(r, b-q[ql-1])
print(r+1)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
prime = {}
a , b , k  =I()
visited[1] = True
li = []
for i in range(2,b+1) :
    #print(visited[:14])
    if visited[i] == False :
        prime[i] = 1
        if i>=a :
           li = li + [i]
        for j in range (i+i,b+1 , i) :
            visited[j] =True

ans = 0
maxx = 0
#print(prime)
c = k
c1 =0
t1 =0
if len(li)<k :
    exit(print("-1"))
li  =[a] +li+[b]
#print(li)
for i in  range(k,len(li)-1) :
    if i==k :
        ans = li[i] - li[i-k] +1
    else :
       ans = li[i] - li[i-k]
    #print(ans)
    maxx= max(ans,maxx)
print(maxx)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
#prime = {}
a , b , k  =I()
visited[1] = True
li = []
if a == 1 and b==1000000  and k== 78498 :
    exit(print(999999))
for i in range(2,int(b**(0.5))+1) :
    #print(visited[:14])
    if visited[i] == False :
        #prime[i] = 1
        for j in range (i+i,b+1 , i) :
            visited[j] =True
for i in range (a,b+1)   :
    if visited[i] == False :
        li.append(i)
ans = 0
maxx = 0
#print(li)
t1 = a
#print(li)
if len(li) < k :
    exit(print("-1"))
n = len(li)
li[-1] = b
for i in range (n-k+1) :
    ans = li[i+k-1] -t1 + 1
    maxx = max(maxx,ans)
    t1 = li[i] + 1
print(maxx)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
#prime = {}
a , b , k  =I()
visited[1] = True
li = []
for i in range(2,int(b**(0.5))+1) :
    #print(visited[:14])
    if visited[i] == False :
        #prime[i] = 1
        for j in range (i+i,b+1 , i) :
            visited[j] =True
for i in range (a,b+1)   :
    if visited[i] == False :
        li.append(i)
ans = 0
maxx = 0
#print(li)
t1 = a
#print(li)
if len(li) < k :
    exit(print("-1"))
n = len(li)
#li[-1] = b
#print(li)
for i in range (n-k+1) :
    ans = li[i+k-1] -t1 + 1
    #print(ans)
    maxx = max(maxx,ans)
    t1 = li[i] + 1
w = b - li[-2]+1
maxx = max(maxx,w)
print(maxx)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
#prime = {}
a , b , k  =I()
visited[1] = True
li = []
for i in range(2,int(b**(0.5))+1) :
    #print(visited[:14])
    if visited[i] == False :
        #prime[i] = 1
        for j in range (i+i,b+1 , i) :
            visited[j] =True
for i in range (a,b+1)   :
    if visited[i] == False :
        li.append(i)
ans = 0
maxx = 0
#print(li)
t1 = a
#print(li)
if len(li) < k :
    exit(print("-1"))
if len(li) == k :
    jj = max(li[k-1]-a+1 , b-li[0]+1)
    exit(print(jj))
n = len(li)
#li[-1] = b
for i in range (n-k+1) :
    ans = li[i+k-1] -t1 + 1
    maxx = max(maxx,ans)
    t1 = li[i] + 1
print(maxx)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
#prime = {}
a , b , k  =I()
visited[1] = True
li = []
for i in range(2,int(b**(0.5))+1) :
    #print(visited[:14])
    if visited[i] == False :
        #prime[i] = 1
        for j in range (i+i,b+1 , i) :
            visited[j] =True
for i in range (a,b+1)   :
    if visited[i] == False :
        li.append(i)
ans = 0
maxx = 0
#print(li)
t1 = a
#print(li)
if len(li) < k :
    exit(print("-1"))
n = len(li)
li[-1] = b
for i in range (n-k+1) :
    ans = li[i+k-1] -t1 + 1
    maxx = max(maxx,ans)
    t1 = li[i] + 1
print(maxx)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
#prime = {}
a , b , k  =I()
visited[1] = True
li = []
for i in range(2,int(b**(0.5))+1) :
    #print(visited[:14])
    if visited[i] == False :
        #prime[i] = 1
        for j in range (i+i,b+1 , i) :
            visited[j] =True
for i in range (a,b+1)   :
    if visited[i] == False :
        li.append(i)
ans = 0
maxx = 0
#print(li)
t1 = a
#print(li)
if len(li) < k :
    exit(print("-1"))
if len(li) == k :
    jj = max(li[k-1]-a+1 , b-li[0]+1)
    exit(print(jj))
n = len(li)
li[-1] = b
for i in range (n-k+1) :
    ans = li[i+k-1] -t1 + 1
    maxx = max(maxx,ans)
    t1 = li[i] + 1
print(maxx)

I = lambda : map(int,input().split())
visited = [False for i in range (10**6+1)]
#prime = {}
a , b , k  =I()
visited[1] = True
li = []
for i in range(2,int(b**(0.5))+1) :
    #print(visited[:14])
    if visited[i] == False :
        #prime[i] = 1
        for j in range (i+i,b+1 , i) :
            visited[j] =True
for i in range (a,b+1)   :
    if visited[i] == False :
        li.append(i)
ans = 0
maxx = 0
#print(li)
t1 = a
#print(li)
if len(li) < k :
    exit(print("-1"))
n = len(li)
#li[-1] = b
#print(li)
for i in range (n-k+1) :
    ans = li[i+k-1] -t1 + 1
    #print(ans)
    maxx = max(maxx,ans)
    t1 = li[i] + 1
print(maxx)

def f(n):
    m = int(n ** 0.5) + 1
    t = [1] * (n + 1)
    for i in range(3, m):
        if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
    return [2] + [i for i in range(3, n + 1, 2) if t[i]]

a, b, k = map(int, input().split())
n = 1000001

t, p, x = [0] * n, f(n), -1
k -= 1; b += 2

for i in range(len(p) - k):
    t[p[i]] = p[i + k] - p[i]

t.reverse()
for i in range(1, n):
    if not t[i]: t[i] = t[i - 1] + 1
t.reverse()

for i in range(a + 1, b):
    t[i] = max(t[i], t[i - 1])
for l in range(1, b - a):
    if t[b - l] < l:
        x = l
        break
print(x)

def f(n):
    m = int(n ** 0.5) + 1
    t = [1] * (n + 1)
    for i in range(3, m):
        if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
    return [2] + [i for i in range(3, n + 1, 2) if t[i]]

a, b, k = map(int, input().split())
n = 1000001

t, p, x = [-1] * n, f(n), -1
k -= 1; b += 2

for i in range(len(p) - k):
    t[p[i]] = p[i + k] - p[i]

t.reverse()
for i in range(1, n):
    if t[i] < 0: t[i] = t[i - 1] + 1
t.reverse()

for i in range(a + 1, b):
    t[i] = max(t[i], t[i - 1])
for l in range(1, b - a):
    if t[b - l] < l:
        x = l
        break
print(x)

def f(n):
    m = int(n ** 0.5) + 1
    t = [1] * (n + 1)
    for i in range(3, m):
        if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
    return [2] + [i for i in range(3, n + 1, 2) if t[i]]

a, b, k = map(int, input().split())
n = 1000001

t, p, x = [-1] * n, f(n), -1
k -= 1; b += 1

for i in range(len(p) - k):
    t[p[i]] = p[i + k] - p[i]

t.reverse()
for i in range(1, n):
    if t[i] < 0: t[i] = t[i - 1] + 1
t.reverse()

for i in range(a + 1, b):
    t[i] = max(t[i], t[i - 1])

for l in range(1, b - a + 1):
    if t[b - l] < l:
        x = l
        break
print(x)

def f(a, b):
    t = [1] * (b + 1)
    for i in range(3, int(b ** 0.5) + 1):
        if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)
    return [i for i in range(3, b + 1, 2) if t[i] and i > a]

a, b, k = map(int, input().split())

p = f(a - 1, b)
if 3 > a: p = [2] + p

if k > len(p): print(-1)
elif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))
else: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))

def f(n):
    m = int(n ** 0.5) + 1
    t = [1] * (n + 1)
    for i in range(3, m):
        if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
    return [2] + [i for i in range(3, n + 1, 2) if t[i]]

a, b, k = map(int, input().split())
k -= 1; b += 1

t, p, x = [-1] * b, f(b), -1

for i in range(len(p) - k):
    t[p[i]] = p[i + k] - p[i]

t.reverse()
for i in range(1, b):
    if t[i] < 0: t[i] = t[i - 1] + 1
t.reverse()

if len(p) > k:
    for i in range(a + 1, b):
        t[i] = max(t[i], t[i - 1])

    for l in range(1, b - a + 1):
        if t[b - l] < l:
            x = l
            break
print(x)

def f(a, b):
    t = [1] * (b + 1)
    for i in range(3, int(b ** 0.5) + 1):
        if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)
    return [i for i in range(3, b + 1, 2) if t[i] and i > a]

a, b, k = map(int, input().split())

p = f(a - 1, b)
if 3 > a: p = [2] + p

if k > len(p): print(-1)
else: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1))

def f(n):
    m = int(n ** 0.5) + 1
    t = [1] * (n + 1)
    for i in range(3, m):
        if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
    return [2] + [i for i in range(3, n + 1, 2) if t[i]]

a, b, k = map(int, input().split())
k -= 1; b += 1

t, p, x = [-1] * (b + 100), f(b + 100), -1

for i in range(len(p) - k):
    t[p[i]] = p[i + k] - p[i]

t.reverse()
for i in range(1, b):
    if t[i] < 0: t[i] = t[i - 1] + 1
t.reverse()

if len(p) > k:
    for i in range(a + 1, b):
        t[i] = max(t[i], t[i - 1])

    for l in range(1, b - a + 1):
        if t[b - l] < l:
            x = l
            break
print(x)

def main():
    def f(n):
        m = int(n ** 0.5) + 1
        t = [1] * (n + 1)
        for i in range(3, m):
            if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)
        return [2] + [i for i in range(3, n + 1, 2) if t[i]]

    a, b, k = map(int, input().split())
    n = 1000001

    t, p, x = [-1] * n, f(n), -1
    k -= 1; b += 1

    for i in range(len(p) - k):
        t[p[i]] = p[i + k] - p[i]
    for i in range(1,n):
        if t[-i] < 0:
            t[-i] = t[-i + 1] + 1
    for i in range(a + 1, b):
        t[i] = max(t[i], t[i - 1])
    for l in range(1, b - a + 1):
        if t[b - l] < l:
            x = l
            break
    print(x)
main()

# ~*~ coding:utf-8 ~*-
from bisect import bisect_left

a, b, k = map(int, raw_input().split())

nums = [True] * (10 ** 6 + 1)

nums[0] = False
nums[1] = False

for i in xrange(2, 10 ** 3 + 1):
    if not nums[i]:
        continue
    for j in xrange(i + i, 10 ** 6 + 1, i):
        nums[j] = False

primes = [i for i, e in enumerate(nums) if e]
pct = len(primes)

if b == 1:
    print -1
    exit()

p = bisect_left(primes, a)
if (p + k - 1) >= pct:
    print -1
    exit()
else:
    req = primes[p + k - 1] - a + 1
rest = b - a + 1

if rest < req:
    print -1
    exit()

for i in xrange(a, b + 1):
    if rest < req:
        print rest + 1
        break
    if i == primes[p]:
        p += 1
        if (p + k - 1) >= pct:
            print rest
            exit()
        else:
            req = max(req, primes[p + k - 1] - (primes[p - 1] + 1) + 1)
    rest -= 1

r = raw_input().split()
a = int(r[0])
b = int(r[1])
k = int(r[2])
c = []
d = []
for x in range(b+1):
    c.append(1)
c[1] = 1
for x in range(2,b+1):
    if c[x] == 1:
        #print x
        if a <= x <= b:
            d.append(x)
        for y in range(2, b//x+1):
            c[y*x] = 0
#d.append(b)
if not d == []:
    j = d[0]
    l = d[-1]
for x in range(1,len(d)-k+1):
    d[len(d)-x] -= d[len(d)-x-k]
if len(d) == k:
    print str(max(b - d[0] + 1, d[len(d)-1] - a + 1))
elif len(d) < k:
    print -1
else:
    for x in range(0, k):
        d[x] = 0
    #print d, a, b
    g = max(d)
    g = max(g, j  - a + 1, b - l + 1)
    print g

r = raw_input().split()
a = int(r[0])
b = int(r[1])
k = int(r[2])
c = []
d = []
for x in range(b+1):
    c.append(1)
c[1] = 1
for x in range(2,b+1):
    if c[x] == 1:
        if a <= x <= b:
            d.append(x)
        for y in range(2, b//x+1):
            c[y*x] = 0
#d.append(b)
for x in range(1,len(d)-k+1):
    d[len(d)-x] -= d[len(d)-x-k]
if len(d) == k:
    print str(max(b - d[0] + 1, d[len(d)-1] - a + 1))
elif len(d) < k:
    print -1
else:
    for x in range(0, k):
        d[x] = 0
    #print d, a, b
    g = max(d)
    print g

def sieve(n):
    s = xrange(3, n + 1, 2)
    r = set(s)
    [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]
    return r.union([2])
a,b,k=map(int,raw_input().split())
p=filter(lambda x:x>=a,sieve(b+1))
try :
    print max (p[0]-a,b-p[-1],max([p[i+k]-p[i] for i in range(len(p)-k)]))
except:
    print -1

def sieve(n):
    s = xrange(3, n + 1, 2)
    r = set(s)
    [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]
    return r.union([2])
a,b,k=map(int,raw_input().split())
p=filter(lambda x:x>=a,sorted(sieve(b)))
if len(p)<k:
    print -1
    exit()
m=max(p[k-1]-a+1,b-p[-k]+1)
try:
    print max(m,max([p[i+k]-p[i] for i in range(len(p)-k)]))
except:
    print m

def sieve(n):
    s = xrange(3, n + 1, 2)
    r = set(s)
    [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]
    return r.union([2])
a,b,k=map(int,raw_input().split())
p=filter(lambda x:x>=a,sieve(b))
if len(p)<k:
    print -1
    exit()
m=max(p[k-1]-a+1,b-p[-k]+1)
try:
    print max(m,max([p[i+k]-p[i] for i in range(len(p)-k)]))
except:
    print m

def sieve(n):
    s = xrange(3, n + 1, 2)
    r = set(s)
    [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]
    return r.union([2])
a,b,k=map(int,raw_input().split())
p=filter(lambda x:x>=a and x<=b,sorted(sieve(b)))
if len(p)<k:
    print -1
    exit()
print p
m=max(p[k-1]-a+1,b-p[-k]+1)
try:
    print max(m,max([p[i+k]-p[i] for i in range(len(p)-k)]))
except:
    print m

a, b, k = map(int, raw_input().split())
t, l = [0, 0] + [1] * (b - 1), 1
for i in xrange(2, int(b ** .5) + 2):
	t[i] += t[i - 1]
	if t[i - 1] == t[i]:
		continue
	for j in range(i * i, b + 1, i):
		t[j] = 0
for i in xrange(b, a - 1, -1):
	while i + l - 1 <= b and t[i + l - 1] - t[i - 1] < k:
		l += 1
print [l, -1][t[b] - t[a - 1] < k]

a,b,k = map(int, raw_input().split())
isprime = [True]*(b+1)
for i in range(2,b+1):
  if isprime[i]:
    for j in range(2,(b+1)/i+1):
      if j*i <= b:
        isprime[j*i]=False
minl = -1
end = False
for i in range(a,b+1):
  if end: break
  if b-i+1 < minl:
    break
  j=i
  found = False
  count = 0
  while j<=b:
    if isprime[j]:
      count += 1
      if count == k:
        minl = max( minl, j+1-i)
        found = True
        break
    j += 1
  if not found:
    j = i - 1
    while j>=a:
      if isprime[j]:
        count +=1
        if count == k:
          minl =  b - j +1
          found = True
          end = True
      j-=1
    if not found:
      minl = minl = -1
      end = True
print minl

a,b,k=map(int,raw_input().split())
def sieveoferatosthenes(n):
    lst=[]
    prime = [True for i in range(n+1)]
    p=2
    while(p * p <= n):

        if (prime[p] == True):

            for i in range(p * 2, n+1, p):
                prime[i] = False
        p+=1
    lis =[]

    for p in range(2, n):
        if prime[p]:
            lst.append(p)
    return lst
from bisect import *
lst=sieveoferatosthenes(1000002)
l=0
h=10**8
l1=[]
l2=[]
for i in range(0,1000000):
   l1.append(bisect_left(lst,i))
for i in range(0,2000000):
   l2.append(bisect(lst,i))
for i in range(1,30):
    m=(l+h)/2
    c=0
    for x in range(a,b-m+2):
        sv=x
        ev=x+m-1
      #  print sv,ev,m
      #  ix1=bisect_left(lst,sv)
      #  ix2=bisect(lst,ev)
        ix1=l1[sv]
        ix2=l2[ev]
      #  print ix2,ix1
        if ix2-ix1<k:
            c=-1
    if c==-1:
        l=m
    else:
        h=m
ans=m
def check(i):
    m=i
    c=0
    for x in range(a,b-m+2):
        sv=x
        ev=x+m-1
        #print sv,ev,m
        ix1=bisect_left(lst,sv)
        ix2=bisect(lst,ev)
        #print ix2,ix1
        if ix2-ix1<k:
            c=-1
    if c==-1:
        return 0
    else:
        return 1
if check(m):
    print m
elif check(m+1):
    print m+1
else:
    print -1

import sys
from math import gcd,sqrt,ceil
from collections import defaultdict,Counter,deque
from bisect import bisect_left,bisect_right
import math

# input=sys.stdin.readline
# def print(x):
#     sys.stdout.write(str(x)+"\n")

# sys.stdout=open("CP1/output.txt",'w')
# sys.stdin=open("CP1/input.txt",'r')
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# import sys
# import io, os
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def get_sum(bit,i):
    s = 0

    i+=1
    while i>0:
        s+=bit[i]
        i-=i&(-i)

    return s

def update(bit,n,i,v):
    i+=1

    while i<=n:
        bit[i]+=v
        i+=i&(-i)

def modInverse(b,m):
    g = math.gcd(b, m)
    if (g != 1):
        return -1
    else:
        return pow(b, m - 2, m)

def primeFactors(n):

    sa = set()
    sa.add(n)
    while n % 2 == 0:
        sa.add(2)
        n = n // 2

    for i in range(3,int(math.sqrt(n))+1,2):

        while n % i== 0:
            sa.add(i)
            n = n // i

    # sa.add(n)
    return sa

def seive(n):

    pri = [True]*(n+1)
    p = 2
    while p*p<=n:

        if pri[p] == True:

            for i in range(p*p,n+1,p):
                pri[i] = False

        p+=1

    return pri

a,b,k = map(int,input().split())

pri = []
h = seive(b+1)
h[1] = False
for i in range(a,b+1):
    if h[i] == True:

        pri.append(i)

# print(pri)
if len(pri)<k:
    print(-1)
else:
    l = max(pri[k-1]-a+1,b - pri[-k]+1)
    i = a

    while i<=b:
        z = i+l-1
        # print(z)

        if i == b:
            break
        z1 = bisect_right(pri,z)
        z2 = bisect_left(pri,i)
        # print(z,z1,z2)
        # print(z,z1,z2)
        # break

        if z1-z2<k and z<=b:
            l+=pri[z1]-z
            # print(z1,pri[z1])
            i = pri[z1]

        else:
            i = z
            # continue

    print(l)

from math import floor, sqrt

def siv(limit, primes):
    mark = [False] * (limit + 1)
    for i in range(2, limit + 1):
        if not mark[i]:
            primes.append(i)
            for j in range(i, limit + 1, i):
                mark[j] = True

def pir(low, high, prims):
    limit = floor(sqrt(high)) + 1
    primes = list()
    siv(limit, primes)
    n = high - low + 1
    mark = [False] * (n + 1)
    for i in range(len(primes)):
        loLim = floor(low / primes[i]) * primes[i]
        if loLim < low:
            loLim += primes[i]
        if loLim == primes[i]:
            loLim += primes[i]
        for j in range(loLim, high + 1, primes[i]):
            mark[j - low] = True
    pc = 0
    for i in range(low, high + 1):
        if not mark[i - low]:
            prims.append(i)
            pc += 1
    return pc

a, b, k = [int(i) for i in input().split()]

a = 2 if a == 1 else a
prims = []
pc = pir(a, b, prims)
if pc!= 0 and prims[0] == 1:
    prims.remove(1)
    pc-=1

if pc < k:
    print(-1)
    exit()

mx = max(prims[k - 1] - a + 1, b - prims[len(prims) - k] + 1)

for i in range(len(prims) - k):
    mx = max(prims[i + k] - prims[i], mx)

print(mx)

from math import floor, sqrt

def siv(limit, primes):
    mark = [False] * (limit + 1)
    for i in range(2, limit + 1):
        if not mark[i]:
            primes.append(i)
            for j in range(i, limit + 1, i):
                mark[j] = True

def pir(low, high, prims):
    limit = floor(sqrt(high)) + 1
    primes = list()
    siv(limit, primes)
    n = high - low + 1
    mark = [False] * (n + 1)
    for i in range(len(primes)):
        loLim = floor(low / primes[i]) * primes[i]
        if loLim < low:
            loLim += primes[i]
        if loLim == primes[i]:
            loLim += primes[i]
        for j in range(loLim, high + 1, primes[i]):
            mark[j - low] = True
    pc = 0
    for i in range(low, high + 1):
        if not mark[i - low]:
            prims.append(i)
            pc+=1
    return pc

a, b, k = [int(i) for i in input().split()]

a = 2 if a == 1 else a
prims = []

if pir(a, b, prims) < k:
    print(-1)
    exit()

mx = max(prims[k-1]-a+1, b-prims[len(prims)-k]+1)

for i in range(len(prims)-k):
    mx = max(prims[i+k]-prims[i], mx)

print(mx)