#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n, m, k;
vector<int> e[MAXN];
int sum[MAXN << 2];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    int col;
    scanf("%d", &col);
    e[col].push_back(i);
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    int sz = e[i].size();
    int ed = 0;
    sum[0] = 0;
    for (int j = 1; j < sz; j++)
      sum[j] = sum[j - 1] + e[i][j] - e[i][j - 1] - 1;
    for (int j = 0; j < sz; j++) {
      if (ed < i) ed = j;
      while (ed < sz && sum[ed] - sum[j] <= k) ed++;
      ans = max(ans, ed - j);
    }
  }
  cout << ans << endl;
  return 0;
}
