#include <bits/stdc++.h>
using namespace std;
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
const int max_n = 200000, max_m = 100000;
int colors[max_n];
vector<pair<int, int> > segments[max_m];
int calc_ans(int color, int k) {
  int res = 0;
  int n = int(segments[color].size());
  if (n == 0) return 0;
  int cur = segments[color][0].second - segments[color][0].first + 1,
      remain_gap = k, r = 1;
  for (int i = 0; i < int(n); i++) {
    r = max(r, i + 1);
    while (r < n) {
      int add_gap =
          segments[color][r].first - segments[color][r - 1].second - 1;
      int add_len = segments[color][r].second - segments[color][r].first + 1;
      if (add_gap <= remain_gap) {
        cur += add_len;
        remain_gap -= add_gap;
        ++r;
      } else {
        break;
      }
    }
    res = max(res, cur);
    if (i + 1 < n) {
      cur -= segments[color][i].second - segments[color][i].first + 1;
      if (i + 1 < r) {
        remain_gap +=
            segments[color][i + 1].first - segments[color][i].second - 1;
      } else {
        cur += segments[color][i + 1].second - segments[color][i + 1].first + 1;
      }
    }
  }
  return res;
}
int main() {
  int n = ni(), m = ni(), k = ni();
  for (int i = 0; i < int(n); i++) {
    colors[i] = ni() - 1;
  }
  int l = 0;
  while (l < n) {
    int r = l + 1;
    while (r < n && colors[r] == colors[l]) {
      ++r;
    }
    segments[colors[l]].push_back(make_pair(l, r - 1));
    l = r;
  }
  int ans = 1;
  for (int i = 0; i < int(m); i++) {
    ans = max(ans, calc_ans(i, k));
  }
  cout << ans << endl;
  return 0;
}
