#include <bits/stdc++.h>
using namespace std;
vector<int> v;
vector<int> pre;
vector<vector<int>> gaps;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  v.resize(n);
  pre.resize(m + 1, -1);
  gaps.resize(m + 1);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (pre[v[i]] != -1) {
      int cum = 0;
      if (gaps[v[i]].size()) cum = gaps[v[i]].back();
      gaps[v[i]].push_back(cum + i - pre[v[i]] - 1);
    }
    pre[v[i]] = i;
  }
  int mx = 0;
  for (int i = 1; i <= m; i++) {
    int cc = 0;
    int lst = 0;
    while (cc < gaps[i].size()) {
      vector<int>::iterator it =
          upper_bound(gaps[i].begin() + cc, gaps[i].end(), k + lst);
      mx = max(mx, int(it - (gaps[i].begin() + cc)));
      if (gaps[i].end() == it) break;
      lst = gaps[i][cc];
      cc++;
    }
  }
  cout << mx + 1;
  return 0;
}
