#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
int main() {
  long long int n, m, k, h = 1, l = 0, ans = 0, number = 0;
  cin >> n >> m >> k;
  vector<vector<long long int>> v, w;
  v.resize(m + 1);
  w.resize(m + 1);
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) {
    v[a[i]].push_back(i);
  }
  for (long long int i = 1; i <= m; i++) {
    for (long long int j = 1; j < v[i].size(); j++) {
      w[i].push_back(v[i][j] - v[i][j - 1] - 1);
    }
  }
  for (long long int i = 1; i <= m; i++) {
    h = 1;
    number = 0;
    l = 0;
    for (long long int j = 0; j < w[i].size(); j++) {
      h++;
      number += w[i][j];
      while (number > k) {
        h--;
        number -= w[i][l];
        l++;
      }
      if (h > ans) ans = h;
    }
    if (h > ans) ans = h;
  }
  cout << ans;
  return 0;
}
