#include <bits/stdc++.h>
using namespace std;
const int MAXM = 111111;
vector<int> v[MAXM];
int n, m, lim, x, lower, upper;
inline bool check(int score) {
  for (int i = 1; i <= m; ++i)
    for (int j = score - 1; j < (int)v[i].size(); ++j) {
      int k = j - score + 1;
      if (v[i][j] - v[i][k] - lim <= score - 1) return true;
    }
  return false;
}
int main() {
  scanf("%d %d %d", &n, &m, &lim);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    v[x].push_back(i);
  }
  lower = 0, upper = n;
  while (lower < upper) {
    int mid = (lower + upper + 1) / 2;
    if (check(mid))
      lower = mid;
    else
      upper = mid - 1;
  }
  printf("%d\n", lower);
}
