#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cout.precision(10);
  int N = 30000000;
  int a, b, k, cntr = 0, prev = 2, cur;
  cin >> a >> b >> k;
  vector<int> p(N + 1, 0);
  vector<bool> prime(N + 1, 1);
  for (long long i = 2; i <= N; i++) {
    if (prime[i]) {
      for (long long j = i * i; j <= N; j += i) {
        prime[j] = 0;
      }
      cntr++;
      if (cntr < k) continue;
      cur = prev;
      while (!prime[cur - 1] || cur == prev) {
        p[cur] = i;
        cur++;
      }
      prev = cur;
    }
  }
  p[1] = p[2];
  int g = -1, ans = 1;
  for (int l = b - a + 1; l > 0; l--) {
    g = max(g, p[b - l + 1] - (b - l + 1));
    if (g >= l) {
      ans = l + 1;
      break;
    }
  }
  if (ans == b - a + 2) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
  }
  return 0;
}
