#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010010;
bool flag[maxn + 1];
int prime[maxn + 1];
int t;
void getpri() {
  int n = maxn;
  int i, j;
  t = 0;
  for (i = 2; i <= n; ++i) {
    if (!flag[i]) prime[t++] = i;
    for (j = 0; j < t && i * prime[j] <= n; ++j) {
      flag[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int bs(int x) {
  int l = 0, r = t, m;
  while (l <= r) {
    m = (l + r) >> 1;
    if (prime[m] == x)
      return m;
    else if (prime[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return l;
}
int main() {
  getpri();
  int l, r, k;
  scanf("%d%d%d", &l, &r, &k);
  int posl = bs(l);
  int posr = bs(r);
  if (prime[posr] != r) posr--;
  int ans = 0;
  if (posr - posl + 1 < k)
    ans = -1;
  else {
    ans = max(ans, prime[posl + k - 1] - l + 1);
    for (int i = posl; i + k <= posr; i++) {
      ans = max(ans, prime[i + k] - prime[i]);
    }
    ans = max(ans, r - prime[posr - k + 1] + 1);
  }
  printf("%d\n", ans);
  return 0;
}
