#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5 + 1;
int n, m, k, res;
vector<int> a[MXN];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    a[x].push_back(i);
  }
  for (int clr = 1; clr <= m; clr++) {
    for (int lo = 0; lo < a[clr].size(); lo++) {
      int l = lo, r = a[clr].size();
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if ((a[clr][mid] - a[clr][lo]) - (mid - lo) <= k)
          l = mid;
        else
          r = mid;
      }
      res = max(res, l - lo + 1);
    }
  }
  printf("%d", res);
  return 0;
}
