#include <bits/stdc++.h>
using namespace std;
struct node {
  int next, w;
} point[200005];
int s[200005], b[200005], last[200005], n, m, k, x, q;
int main() {
  int t, ans, m, p;
  memset(s, 0, sizeof(s));
  memset(point, 0, sizeof(point));
  memset(b, 0, sizeof(b));
  scanf("%d%d%d", &n, &m, &k);
  ans = q = 0;
  for (t = 1; t <= n; t++) {
    scanf("%d", &x);
    s[x]++;
    if (!b[x]) {
      b[x] = t;
      last[x] = t;
      point[t].w = s[x];
    } else if (x != q) {
      point[last[x]].next = t;
      point[t].w = s[x];
      last[x] = t;
    }
    q = x;
    m = t - b[x] + 1;
    while (m - (s[x] - point[b[x]].w + 1) > k) {
      b[x] = point[b[x]].next;
      m = t - b[x] + 1;
    }
    if (s[x] - point[b[x]].w + 1 > ans) ans = s[x] - point[b[x]].w + 1;
  }
  printf("%d\n", ans);
  return 0;
}
