#include <bits/stdc++.h>
using namespace std;
vector<int> ord[100100];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    ord[t - 1].push_back(i);
  }
  int best = 0;
  for (int i = 0; i < 100100; i++) {
    for (int j = 0; j < ord[i].size(); j++) {
      ord[i][j] -= j;
    }
    for (int j = 0; j < ord[i].size(); j++) {
      int cur = ord[i][j];
      int nxt = cur + k;
      int pos = upper_bound(ord[i].begin(), ord[i].end(), nxt) - ord[i].begin();
      best = max(best, pos - j);
    }
  }
  cout << best << endl;
}
