#include <bits/stdc++.h>
using namespace std;
template <class stl>
void DBGSTL(stl a) {
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++) {
    cerr << *i << " ";
  }
  cerr << "\n";
  return;
}
vector<int> pos[200010 / 2];
int main() {
  int n, m, k, x;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    pos[x].push_back(i + 1);
  }
  int mx = -1;
  for (int i = 1; i <= m; i++) {
    int st = 0, nd = 0, cnt = 0, lst = 0, lstst = 0;
    int nxt = 0;
    for (int j = 0; j < pos[i].size(); j++) {
      st = j;
      if (st != lstst) {
        cnt -= (pos[i][st] - pos[i][lstst] - 1);
      }
      while (cnt + ((nd == lst) ? 0 : (pos[i][nd] - pos[i][lst] - 1)) <= k &&
             nd < pos[i].size()) {
        cnt += (nd == lst) ? 0 : (pos[i][nd] - pos[i][lst] - 1);
        mx = max(mx, nd - st + 1);
        lst = nd;
        nd++;
      }
      lstst = st;
    }
  }
  cout << mx << endl;
  return 0;
}
