#include <bits/stdc++.h>
using namespace std;
int T, N, K;
int A[200005], D[200005], C[200005], S[200005];
vector<int> pos[200005];
int main() {
  scanf("%d%*d%d", &N, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%d", A + i);
    pos[A[i]].push_back(i);
  }
  for (int i = 1; i <= N; i++) {
    auto it = lower_bound((pos[A[i]]).begin(), (pos[A[i]]).end(), i);
    if (it == pos[A[i]].begin()) {
      D[i] = 1;
      C[i] = 0;
      S[i] = i;
    } else {
      int j = *--it;
      int val = C[j] + (i - j - 1), dpval = D[j] + 1, p = S[j];
      while (val > K) {
        int nxt = *upper_bound((pos[A[i]]).begin(), (pos[A[i]]).end(), p);
        val -= nxt - p - 1;
        p = nxt;
        dpval--;
      }
      D[i] = dpval;
      C[i] = val;
      S[i] = p;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) ans = max(ans, D[i]);
  static int ts = 0;
  printf("%d\n", ans);
}
