#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2 * 1000 * 100 + 10;
int n, m, a[Maxn], k, b[Maxn];
vector<pair<int, int> > s[Maxn];
vector<unsigned long long> su[Maxn];
inline void input() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
}
int find_best(int v) {
  int best = 0;
  for (int i = 0; i < s[v].size(); i++) {
    int f = i, l = s[v].size() - 1, mid = (f + l) / 2;
    while (f <= l) {
      mid = (f + l) / 2;
      if (su[v][mid] - su[v][i] <= k)
        f = mid + 1;
      else
        l = mid - 1;
    }
    if (su[v][mid] - su[v][i] > k) mid--;
    best = max(best, mid - i);
  }
  return best;
}
inline void solve() {
  for (int i = 0; i < n; i++) {
    int c = a[i] - 1;
    if (s[c].size())
      s[c].push_back(make_pair(i - s[c][s[c].size() - 1].second - 1, i));
    else
      s[c].push_back(make_pair(0, i));
  }
  for (int i = 0; i < m; i++)
    if (s[i].size()) {
      su[i].push_back(s[i][0].first);
      for (int j = 1; j < s[i].size(); j++)
        su[i].push_back(su[i][j - 1] + s[i][j].first);
    }
  for (int i = 0; i < m; i++)
    if (s[i].size()) b[i] = find_best(i) + 1;
}
int main() {
  input();
  solve();
  cout << *max_element(b, b + m);
}
