#include <bits/stdc++.h>
using namespace std;
bool f[1000001];
long g[1000001];
int main() {
  long a, b, k, n = 0, mi = 0;
  cin >> a >> b >> k;
  f[0] = f[1] = 0;
  for (long i = 2; i <= b; i++) f[i] = 1;
  for (long i = 2; i <= b; i++)
    if (f[i]) {
      if (a <= i) {
        g[n++] = i;
        if (k >= n)
          mi = max(mi, i - a + 1);
        else
          mi = max(mi, g[n - 1] - g[n - k - 1]);
      }
      for (long j = (i << 1); j <= b; j += i) f[j] = 0;
    }
  if (k <= n) mi = max(mi, b - g[n - k] + 1);
  if (k > n)
    cout << -1 << endl;
  else
    cout << mi << endl;
}
