#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
vector<int> prim;
bool u[N];
int a, b, k;
void pre() {
  for (int i = 2; i < N; i++)
    if (!u[i]) {
      prim.push_back(i);
      int k = i << 1;
      while (k < N) u[k] = 1, k += i;
    }
}
vector<int> tmp;
void init() {
  cin >> a >> b >> k;
  for (int i = 0; i < prim.size(); i++)
    if (prim[i] >= a && prim[i] <= b) tmp.push_back(prim[i]);
  if (tmp.size() < k) {
    cout << -1 << endl;
    return;
  }
  int s = 0, t = k - 1, ad = max(0, tmp[0] - a);
  int ans = 0;
  while (t < tmp.size()) {
    ans = max(ans, tmp[t] - tmp[s] + 1 + ad);
    s++;
    t++;
    ad = tmp[s] - tmp[s - 1] - 1;
  }
  t = tmp.size() - 1, s = t - k + 1, ad = max(0, b - tmp[t]);
  while (s >= 0) {
    ans = max(ans, tmp[t] - tmp[s] + 1 + ad);
    s--;
    t--;
    ad = tmp[t + 1] - tmp[t] - 1;
  }
  cout << ans << endl;
}
int main() {
  pre();
  init();
  return 0;
}
