#include <bits/stdc++.h>
using namespace std;
int buf[1001000];
int i, j;
int p[1001000];
int q[2 * 1001000];
int l, r, head, tail, ans;
int main() {
  for (i = 0; i < 1001000; i++) buf[i] = i;
  for (i = 2; i < 1001000; i++) {
    if (buf[i] != 0) {
      for (j = i + i; j < 1001000; j += i) buf[j] = 0;
    }
  }
  int cnt = 0;
  for (i = 2; i < 1001000; i++) {
    if (buf[i] != 0) p[cnt++] = i;
  }
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);
  l = -1;
  r = -1;
  for (i = 0; i < cnt; i++) {
    if (p[i] >= a) {
      l = i;
      break;
    }
  }
  for (i = 0; i < cnt; i++)
    if (p[i] > b) {
      r = i - 1;
      break;
    }
  ans = -1;
  if (r - l + 1 < k) {
    printf("-1\n");
    return 0;
  }
  ans = max(ans, p[l + k - 1] - a + 1);
  ans = max(ans, b - p[r - k + 1] + 1);
  for (i = l; i <= r - k; i++) ans = max(ans, p[i + k] - p[i]);
  printf("%d\n", ans);
  return 0;
}
