#include <bits/stdc++.h>
using namespace std;
int in() {
  int x = 0, c;
  for (; (unsigned int)((c = getchar()) - '0') >= 10;) {
    if (c == '-') return -in();
    if (!~c) throw ~0;
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while ((unsigned int)((c = getchar()) - '0') < 10);
  return x;
}
vector<pair<int, int> > color[100010];
vector<int> dist[100010];
vector<int> cost[100010];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, K;
  cin >> n >> m >> K;
  int prevcolor = 0, previdx = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    t--;
    if (i) {
      if (prevcolor != t) {
        color[prevcolor].push_back(make_pair(previdx, i - 1));
        prevcolor = t;
        previdx = i;
      }
    } else {
      prevcolor = t;
      previdx = i;
    }
  }
  color[prevcolor].push_back(make_pair(previdx, n - 1));
  for (int i = 0; i < m; i++) {
    if (color[i].size() == 0) continue;
    dist[i].push_back(0);
    cost[i].push_back(0);
    cost[i].push_back(color[i][0].second - color[i][0].first + 1);
    for (int j = 1; j < color[i].size(); j++) {
      dist[i].push_back(color[i][j].first - color[i][j - 1].second - 1 +
                        dist[i].back());
      cost[i].push_back(color[i][j].second - color[i][j].first + 1 +
                        cost[i].back());
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (color[i].size() == 0) continue;
    vector<int> &d = dist[i];
    vector<int> &c = cost[i];
    for (int j = 0; j < color[i].size(); j++) {
      int allowIndex =
          upper_bound(d.begin(), d.end(), K + d[j]) - d.begin() - 1;
      ans = max(c[allowIndex + 1] - c[j], ans);
    }
  }
  cout << ans << endl;
}
