#include <bits/stdc++.h>
using namespace std;
int a, b, kk;
int s[1000599];
vector<int> PRIMES;
void sito(int size) {
  for (int i = 2; i <= (size); ++i) {
    int j = i;
    if (s[i] == 0) {
      PRIMES.push_back(i);
      while (j <= size) {
        s[j] = 1;
        j += i;
      }
    }
  }
}
bool sim(int a, int b, int l, int p) {
  if (p > PRIMES.size()) return false;
  int ind = 0;
  while (PRIMES[ind] < a) ind++;
  int additionalcheck = ind;
  if (a != PRIMES[ind])
    if (a + l - 1 < PRIMES[ind + p - 1]) return false;
  while (PRIMES[ind] + l <= b) {
    if (PRIMES[ind] + l < PRIMES[ind + p]) return false;
    ind++;
  }
  if (l == b - a + 1 && a == PRIMES[additionalcheck]) {
    if (b < PRIMES[additionalcheck + p - 1]) return false;
  }
  return true;
}
int binsearch(int p, int k) {
  while (k > p) {
    int expected = (p + k) / 2;
    if (sim(a, b, expected, kk))
      k = expected;
    else
      p = expected + 1;
  }
  if (sim(a, b, p, kk))
    return p;
  else
    return -1;
}
int main() {
  sito(1000030);
  scanf("%d%d%d", &a, &b, &kk);
  cout << binsearch(1, b - a + 1) << endl;
  return 0;
}
