#include <bits/stdc++.h>
using namespace std;
vector<int> resh(int N) {
  int* lp = new int[N + 1];
  memset(lp, 0, 4 * N + 4);
  vector<int> pr;
  for (int i = 2; i <= N; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
      lp[i * pr[j]] = pr[j];
  }
  delete[] lp;
  return pr;
}
int main() {
  vector<int> rs = resh(1000009);
  int a, b, k;
  cin >> a >> b >> k;
  int prev = a;
  int cur = 0;
  while (a > rs[cur]) cur++;
  int c = cur;
  while (rs[c] <= b) c++;
  if (c - cur < k || a > b) {
    cout << -1 << endl;
    return 0;
  }
  int l = rs[cur + k - 1] - prev + 1;
  int p;
  while (rs[cur + k - 1] <= b) {
    p = rs[cur + k - 1] - prev;
    prev = rs[cur];
    if (p > l) l = p;
    cur++;
  }
  if (c >= k)
    p = b - rs[c - k] + 1;
  else
    p = 1;
  if (p > l) l = p;
  cout << l << endl;
  return 0;
}
