#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 10;
long long N, M, K, ans, val[MAXN], pre[MAXN], lst[MAXN], nxt[MAXN], dis[MAXN],
    fir[MAXN];
int main() {
  scanf("%lld%lld%lld", &N, &M, &K);
  for (long long i = 1; i <= N; i++) {
    scanf("%lld", val + i);
    if (!fir[val[i]]) fir[val[i]] = i;
    pre[i] = lst[val[i]];
    dis[lst[val[i]]] = i - lst[val[i]] - 1;
    nxt[lst[val[i]]] = i;
    lst[val[i]] = i;
  }
  for (long long i = 1; i <= M; i++)
    if (lst[i]) nxt[lst[i]] = N + 1;
  for (long long i = 1; i <= M; i++) {
    if (fir[i]) {
      long long sum = 0, cnt = 1;
      for (long long st = fir[i], ed = fir[i]; st <= N; st = nxt[st]) {
        while (ed < st) sum += dis[ed], ed = nxt[ed], cnt++;
        while (sum + dis[ed] <= K && ed != lst[i])
          sum += dis[ed], ed = nxt[ed], cnt++;
        ans = max(ans, cnt);
        sum -= dis[st], cnt--;
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
