#include <bits/stdc++.h>
using namespace std;
const int MX = (1 << 20);
int n, xoxo, K, x;
int calc(vector<int> &v) {
  if (v.empty()) return 0;
  int sz = v.size(), ret = 0;
  int it1 = 0, it2 = 0;
  while (1) {
    if (it2 == sz) break;
    int seg = it2 - it1 + 1, len = v[it2] - v[it1] + 1;
    if (len - seg <= K) {
      ret = max(ret, seg);
      it2++;
      continue;
    }
    it1++;
  }
  return ret;
}
vector<int> v[MX];
int main() {
  int ans = 0;
  cin >> n >> xoxo >> K;
  for (int j = 1; j <= n; j++) {
    scanf("%d", &x);
    v[x].push_back(j);
  }
  for (int j = 1; j <= xoxo; j++) {
    ans = max(ans, calc(v[j]));
  }
  cout << ans << endl;
}
