#include <bits/stdc++.h>
using namespace std;
long long int fast_expo(long long int x, long long int p) {
  if (p == 0)
    return 1;
  else if (p % 2 == 0) {
    long long int t = fast_expo(x, p / 2) % 998244353;
    return (t * t) % 998244353;
  } else
    return (x * (fast_expo(x, p - 1)) % 998244353) % 998244353;
}
int main() {
  vector<int> v[200005];
  int n, m, k;
  cin >> n >> m >> k;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v[x].push_back(i);
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    int l = 0;
    for (int j = 0; j < v[i].size(); j++) {
      while (l < v[i].size() && (v[i][l] - v[i][j] + 1) - (l - j + 1) <= k) l++;
      ans = max(ans, l - j);
    }
  }
  cout << ans << endl;
}
