#include <bits/stdc++.h>
using namespace std;
struct val_ind {
  int val, ind;
};
int solve(val_ind* A, int n, int k) {
  int result = 0;
  int gaps_used = 0;
  int i = 0, j = i;
  while (i < n) {
    while (j + 1 < n && (A[j + 1].ind - A[j].ind - 1) + gaps_used <= k) {
      gaps_used += A[j + 1].ind - A[j].ind - 1;
      j++;
    }
    result = max(result, j - i + 1);
    if (i + 1 >= n) break;
    gaps_used -= (A[i + 1].ind - A[i].ind - 1);
    i++;
    if (j < i) {
      j = i;
      gaps_used = 0;
    }
  }
  return result;
}
bool cmp(const val_ind& A, const val_ind& B) {
  return A.val < B.val || (A.val == B.val && A.ind < B.ind);
}
const int MAXN = 2 * 100 * 1000 + 9;
int n, m, k;
val_ind A[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> A[i].val;
    A[i].ind = i;
  }
  sort(A, A + n, cmp);
  int iter_L = 0, iter_R;
  int result = 0;
  while (iter_L < n) {
    iter_R = iter_L;
    while (iter_R + 1 < n && A[iter_R + 1].val == A[iter_L].val) iter_R++;
    result = max(result, solve(A + iter_L, iter_R - iter_L + 1, k));
    iter_L = iter_R + 1;
  }
  cout << result;
  return 0;
}
