#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int k;
int arr[N];
vector<int> v[N];
vector<int> gap[N];
int solve(int l, int r, int c) {
  int m = (l + r) >> 1;
  if (l == r) return v[c][l];
  if (l >= r) return 0;
  if (r == l + 1) {
    if (gap[c][l] <= k)
      return v[c][l] + v[c][r];
    else
      return 0;
  }
  int lt = m;
  int rt = m;
  int cost = 0;
  int ans = v[c][m];
  int maxi = max(solve(l, m, c), solve(m, r, c));
  while (cost + gap[c][rt] <= k) {
    cost += gap[c][rt];
    ans += v[c][rt + 1];
    rt++;
    if (rt >= r) break;
  }
  maxi = max(ans, maxi);
  while (rt >= m) {
    if (lt == l) break;
    while (cost + gap[c][lt - 1] <= k) {
      cost += gap[c][lt - 1];
      ans += v[c][lt - 1];
      lt--;
      if (lt == l) break;
    }
    if (maxi < ans) maxi = ans;
    if (rt < l + 1) break;
    ans -= v[c][rt];
    cost -= gap[c][--rt];
  }
  return maxi;
}
signed main() {
  int n, m;
  cin >> n >> m >> k;
  int count[n + 5];
  count[n] = -1;
  count[n + 1] = -1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    count[i] = -1;
  }
  int ct = 1;
  arr[n] = n + 2;
  count[arr[0]] = 0;
  for (int i = 1; i < n + 1; i++) {
    if (arr[i] == arr[i - 1]) ct++;
    if (arr[i] != arr[i - 1]) {
      v[arr[i - 1]].push_back(ct);
      if (count[arr[i]] != -1) {
        gap[arr[i]].push_back(i - count[arr[i]] - 1);
      }
      count[arr[i - 1]] = i - 1;
      ct = 1;
    }
  }
  int maxi = -1;
  for (int i = 1; i <= m; i++) {
    maxi = max(solve(0, v[i].size() - 1, i), maxi);
  }
  cout << maxi << endl;
  return 0;
}
