#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
int n, m, k;
int ret = 0;
void solve(vector<int>& vec) {
  int len = vec.size();
  int j = 0;
  for (int i = 0; i < len; ++i) {
    int tmp;
    while (j + 1 < len) {
      tmp = vec[j + 1] - vec[i] - 1 - (j - i);
      if (tmp > k) break;
      ++j;
    }
    if (j - i + 1 > ret) ret = j - i + 1;
    if (j == len - 1) break;
  }
  return;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int t;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t);
    v[t].push_back(i);
  }
  for (int i = 1; i <= m; ++i) solve(v[i]);
  printf("%d\n", ret);
  return 0;
}
