#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> vec[100010];
  long long n, m, k, ans = 0, x;
  scanf("%lld %lld %lld", &n, &m, &k);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &x);
    vec[x].push_back(i);
  }
  for (long long i = 1; i <= m; i++) {
    long long Size = vec[i].size(), lft = 0, rht = 0, mx = 0;
    while (rht < Size) {
      if (vec[i][rht] - vec[i][lft] + 1 - k <= rht - lft + 1) {
        mx = max(rht - lft + 1, mx);
        rht++;
      } else
        lft++;
    }
    ans = max(ans, mx);
  }
  printf("%lld\n", ans);
  return 0;
}
