#include <bits/stdc++.h>
using namespace std;
void solutionE();
int main() {
  ios_base::sync_with_stdio(false);
  solutionE();
  return EXIT_SUCCESS;
}
long long n, m, k, a[400000];
vector<long long> b[400000];
void solve() {
  for (long long i = 0; i < n; ++i) b[a[i]].push_back(i);
  long long ans = 0;
  for (long long i = 0; i < m; ++i) {
    if (b[i].empty()) continue;
    long long p1 = 0, p2 = 0, s = 0, c = 0;
    while (p1 < b[i].size()) {
      while (p1 < b[i].size() && s <= k) {
        ans = max(ans, c);
        ++c;
        if (p1 > 0) s += b[i][p1] - b[i][p1 - 1] - 1;
        ++p1;
      }
      while (p2 < p1 && s > k) {
        --c;
        s -= b[i][p2 + 1] - b[i][p2] - 1;
        ++p2;
      }
      ans = max(ans, c);
    }
  }
  cout << ans << endl;
}
void solutionE() {
  for (; cin >> n >> m >> k;) {
    for (long long i = 0; i < m; ++i) b[i].clear();
    for (long long i = 0; i < n; ++i) {
      cin >> a[i];
      --a[i];
    }
    solve();
    cerr << endl;
  }
}
