#include <bits/stdc++.h>
using namespace std;
vector<int> getaux(vector<int> pos) {
  vector<int> aux;
  int cnt = 1;
  for (int i = 0; i < pos.size() - 1; i++) {
    if (pos[i] + 1 == pos[i + 1]) {
      cnt++;
    } else {
      aux.push_back(cnt);
      aux.push_back(pos[i + 1] - pos[i] - 1);
      cnt = 1;
    }
  }
  aux.push_back(cnt);
  return aux;
}
int solve(vector<int> pos, int k) {
  vector<int> aux = getaux(pos);
  int gap = 0, sum = 0;
  int ans = 0;
  int l = 1;
  for (int i = 0; i < (int)aux.size(); i += 2) {
    sum += aux[i];
    ans = max(sum, ans);
    if (i == (int)aux.size() - 1) break;
    gap += aux[i + 1];
    while (gap > k) {
      gap -= aux[l];
      sum -= aux[l - 1];
      l += 2;
    }
  }
  return ans;
}
vector<vector<int> > all(2000100);
int main() {
  int n, m, k, in;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &in);
    all[in].push_back(i);
  }
  int ans = 0;
  for (int i = 0; i <= m; i++) {
    if (all[i].size()) ans = max(ans, solve(all[i], k));
  }
  cout << ans << endl;
}
