#include <bits/stdc++.h>
using namespace std;
bool func(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
    return true;
  }
}
bool prime[1000001];
int acc[1000001];
;
void fun() {
  for (int i = 0; i < 1000001; i++) {
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i <= 1000001; i++) {
    if (prime[i] == true) {
      for (int j = i * 2; j <= 1000001; j = j + i) {
        prime[j] = false;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  fun();
  int a, b, k, c = 0;
  cin >> a >> b >> k;
  for (int i = a; i <= b; i++) {
    if (prime[i] == true) c++;
  }
  if (c < k) {
    cout << -1;
    return 0;
  } else {
    for (int i = 1; i < 1000005; i++) {
      acc[i] = prime[i] + acc[i - 1];
    }
    int maxi = 0, f = 0;
    for (int i = a; i <= b; i++) {
      int l = a, e = b, mid, res;
      while (l <= e) {
        mid = (l + e) / 2;
        f = acc[i] + k - 1;
        if (acc[mid] == acc[i] + k - 1) {
          res = mid;
          l = mid + 1;
        }
        if (acc[mid] > acc[i] + k - 1) {
          e = mid - 1;
        } else {
          l = mid + 1;
        }
      }
      int g = res - i + 2 - prime[i];
      maxi = max(res - i + 2 - prime[i], maxi);
    }
    cout << maxi;
  }
  return 0;
}
