#include <bits/stdc++.h>
int f[1000010], s[1000010], hash[1000010];
void init() {
  int i, j, k = 0;
  memset(f, 1, sizeof(f));
  memset(s, 0, sizeof(s));
  for (i = 2; i * i < 1000010; i++)
    for (j = i; j * i < 1000010; j++) f[i * j] = 0;
  f[1] = 0;
  for (i = 1; i < 1000010; i++) {
    s[i] = s[i - 1];
    if (f[i]) s[i]++;
  }
  for (i = 1; i < 1000010; i++) {
    if (f[i]) hash[++k] = i;
  }
}
int main() {
  int a, b, k, n, m, i, j, ml, w;
  init();
  while (scanf("%d %d %d", &a, &b, &k) != EOF) {
    if (s[b] - s[a - 1] < k)
      printf("-1\n");
    else {
      ml = -1;
      for (i = a; hash[s[i - 1] + k] <= b; i++) {
        ml =
            (ml > hash[s[i - 1] + k] - i + 1) ? ml : hash[s[i - 1] + k] - i + 1;
        if (hash[s[i] + k] > b) w = b - i + 1;
      }
      ml = (ml > w) ? ml : w;
      printf("%d\n", ml);
    }
  }
  return 0;
}
