#include <bits/stdc++.h>
using namespace std;
int n, m, k2;
int ar[200005];
int last_ind[200005];
vector<pair<int, int> > v[200005];
int mx;
void check(int in) {
  int s = v[in].size();
  if (s == 0) return;
  int i, j, cnt, kc = 0;
  i = 0;
  j = 1;
  cnt = v[in][0].first;
  while (i < s) {
    while (j < s && kc + v[in][j].second <= k2) {
      cnt += v[in][j].first, kc += v[in][j].second;
      j++;
    }
    mx = max(cnt, mx);
    cnt -= v[in][i].first;
    i++;
    kc -= v[in][i].second;
    if (j < i) j = i;
  }
}
int main() {
  memset(last_ind, -1, sizeof(last_ind));
  scanf("%d %d", &n, &m);
  scanf("%d", &k2);
  int i, j, k;
  i = 0;
  while (i < n) scanf("%d", &ar[i++]);
  i = 0;
  while (i < n) {
    k = ar[i];
    j = i + 1;
    while (j < n && ar[j] == k) j++;
    v[k].push_back(pair<int, int>(j - i, i - last_ind[k] - 1));
    last_ind[k] = j - 1;
    i = j;
  }
  mx = 0;
  i = 1;
  while (i <= m) {
    check(i);
    i++;
  }
  printf("%d\n", mx);
  return 0;
}
