#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;
const ll INF = 1e18 + 1;
int get(vector<int> &v, int k) {
  int n = v.size();
  int i = 0, j = 0, ans = 0, sum = 0;
  while (i < n && j < n) {
    if (sum <= k)
      sum += v[i++];
    else
      sum -= v[j++];
    if (sum <= k) ans = max(ans, i - j);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, m;
  cin >> n >> m >> k;
  vector<int> v(n);
  vector<vector<int> > f(m + 1);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    f[v[i]].emplace_back(i);
  }
  vector<vector<int> > diff(m + 1);
  int ans = 0;
  for (int i = 0; i < f.size(); i++) {
    for (int j = 1; j < f[i].size(); j++)
      diff[i].emplace_back(f[i][j] - f[i][j - 1] - 1);
    ans = max(ans, get(diff[i], k));
  }
  cout << ans + 1 << "\n";
  return 0;
}
