#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
int beg[N];
int nxt[N];
int to[N];
int tot;
int a[N];
void add(int x, int y) {
  ++tot;
  nxt[tot] = beg[x];
  to[tot] = y;
  beg[x] = tot;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    add(x, i);
  }
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    int siz = 0;
    for (int j = beg[i]; j; j = nxt[j]) a[++siz] = to[j];
    if (siz == 0) continue;
    reverse(a + 1, a + 1 + siz);
    for (int r = 1, l = 1; r <= siz; ++r) {
      for (; l < r && a[r] - a[l] + 1 > k + r - l + 1; ++l)
        ;
      ans = max(ans, r - l + 1);
    }
  }
  cout << ans;
}
