#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, x, y;
void solve() {
  cin >> n >> m >> k;
  vector<long long int> v[200005];
  for (long long int i = 1; i <= n; i++) {
    cin >> x;
    v[x].push_back(i);
  }
  long long int ans = 0;
  for (long long int i = 1; i <= m; i++) {
    for (long long int l = 0; l < v[i].size(); l++) {
      long long int lo = l, hi = v[i].size();
      while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        if ((v[i][mid] - v[i][l] + 1) - (mid - l + 1) <= k)
          lo = mid;
        else
          hi = mid;
      }
      ans = max(ans, (v[i][lo] - v[i][l] + 1 -
                      (v[i][lo] - v[i][l] + 1 - (lo - l + 1))));
    }
  }
  cout << ans << "\n";
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
