#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
struct data {
  int next, from;
} e[maxn];
int a[maxn], last[maxn], loc[maxn], sum[maxn], n, m, k;
int ans;
inline void ref(int pos, int x) {
  while (pos - loc[x] + 1 - (sum[pos] - sum[loc[x]] + 1) > k) {
    loc[x] = e[loc[x]].next;
  }
  ans = max(ans, sum[pos] - sum[loc[x]] + 1);
}
inline void solve() {
  for (int i = 1; i <= n; i++) {
    int L = last[a[i]];
    e[L].next = i;
    e[i].from = L;
    sum[i] = sum[L] + 1;
    ref(i, a[i]);
    last[a[i]] = i;
  }
  cout << ans;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (!loc[a[i]]) loc[a[i]] = i;
  }
  solve();
  return 0;
}
