#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans;
int sz[100003];
vector<int> v[100003];
bool f(int mid) {
  for (int i = 1; i <= m; i++)
    for (int j = 0; j <= sz[i] - mid; j++)
      if (v[i][j + mid - 1] - v[i][j] + 1 <= mid + k) return true;
  return false;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    v[x].push_back(i);
    sz[x]++;
  }
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (f(mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  printf("%d\n", ans);
  return 0;
}
