#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n, m, k, c, ans = 1;
vector<int> vec[N];
void check(vector<int> vec) {
  if (vec.empty()) return;
  int r = 0;
  for (int l = 0; l < vec.size(); l++) {
    r = max(r, l);
    while (r + 1 < vec.size() &&
           (vec[r + 1] - vec[l] + 1 - (r + 1 - l + 1)) <= k) {
      r++;
      ans = max(ans, r - l + 1);
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> c, vec[c].push_back(i);
  for (int i = 0; i < N; i++) check(vec[i]);
  cout << ans;
  return 0;
}
