#include <bits/stdc++.h>
using namespace std;
int64_t max(int32_t a, int64_t b) { return max((int64_t)a, b); }
inline void mmax(int64_t &a, int64_t b) { a = max(a, b); }
inline void mmin(int64_t &a, int64_t b) { a = min(a, b); }
vector<pair<int64_t, int64_t> > clr[111000];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int64_t n, m, k;
  cin >> n >> m >> k;
  vector<int64_t> ar(n);
  int64_t c = 1;
  cin >> ar[0];
  for (int64_t i = 1; i < n; i++) {
    cin >> ar[i];
    if (ar[i] == ar[i - 1])
      c++;
    else {
      clr[ar[i - 1]].push_back({c, i - 1});
      c = 1;
    }
  }
  int64_t ans = 0;
  clr[ar.back()].push_back({c, ar.size() - 1});
  for (int64_t i = 1; i <= m; i++) {
    if (clr[i].empty()) continue;
    int64_t x = clr[i][0].first;
    int64_t skipped = 0;
    int64_t l = 0;
    ans = max(ans, x);
    for (int64_t j = 1; j < clr[i].size(); j++) {
      while (skipped + (clr[i][j].second - clr[i][j - 1].second -
                        (clr[i][j].first - 1) - 1) >
                 k &&
             l < j) {
        skipped -= (clr[i][l + 1].second - clr[i][l].second -
                    (clr[i][l + 1].first - 1) - 1);
        x -= clr[i][l].first;
        skipped = max(skipped, 0);
        l++;
      }
      x += clr[i][j].first;
      if (l != j)
        skipped += (clr[i][j].second - clr[i][j - 1].second -
                    (clr[i][j].first - 1) - 1);
      ans = max(ans, x);
    }
    ans = max(ans, x);
  }
  cout << ans;
}
