#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int inf = (int)1e9;
const int MAX_N = 200 * 1000 + 100;
int n, m, k;
int arr[MAX_N];
int num[MAX_N];
bool isok(int len) {
  int maxi = -1;
  int check = len;
  len = min(n, len + k);
  memset(num, 0, sizeof num);
  int i;
  for (i = 0; i < len; i++) {
    num[arr[i]]++;
    maxi = max(maxi, num[arr[i]]);
  }
  if (maxi >= check) return 1;
  for (; i < n; i++) {
    int x = arr[i - len];
    int y = arr[i];
    if (x == y) continue;
    num[x]--;
    num[y]++;
    maxi = max(maxi, num[y]);
    if (maxi >= check) return 1;
  }
  return 0;
}
int cal() {
  int lo = 1, hi = n + 1;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (isok(mid)) {
      lo = mid + 1;
    } else {
      hi = mid;
    }
  }
  return lo - 1;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  int ans = cal();
  cout << ans << endl;
  return 0;
}
