#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 1e7;
bool bt[maxn + 5];
vector<int> primes;
int main() {
  cout.sync_with_stdio(false);
  cin.tie(NULL);
  bt[1] = 1;
  for (long long int i = 2; i <= maxn; i++)
    if (!bt[i]) {
      primes.push_back(i);
      for (long long int j = i * i; j <= maxn; j += i) bt[j] = 1;
    }
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  for (int i = a; i <= b; i++)
    if (!bt[i]) cnt++;
  if (cnt < k)
    cout << -1 << endl;
  else {
    int res = 0;
    for (int i = a; i <= b; i++) {
      int esq = lower_bound(primes.begin(), primes.end(), i) - primes.begin();
      int dir = esq + k - 1;
      if (dir >= (int)primes.size() || primes[esq] > b || primes[dir] > b) {
        res = max(res, b - (i - 1) + 1);
        break;
      } else
        res = max(res, primes[dir] - primes[esq] + primes[esq] - i + 1);
    }
    cout << res << endl;
  }
  return 0;
}
