#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 1;
  vector<vector<long long> > arr(m, vector<long long>());
  for (long long i = 0; i < n; i++) {
    arr[a[i] - 1].push_back(i);
  }
  for (long long j = 0; j < m; j++) {
    vector<long long> diff;
    for (long long i = 1; i < arr[j].size(); i++) {
      diff.push_back(arr[j][i] - arr[j][i - 1] - 1);
    }
    for (long long i = 1; i < diff.size(); i++) {
      diff[i] += diff[i - 1];
    }
    long long maxlen = 0;
    long long sum = 0;
    for (long long i1 = 0; i1 < diff.size(); i1++) {
      long long x = 0;
      if (i1) x = diff[i1 - 1];
      long long ind =
          upper_bound(diff.begin() + i1, diff.end(), x + k) - diff.begin();
      maxlen = max(maxlen, ind - i1);
    }
    ans = max(maxlen + 1, ans);
  }
  cout << ans << endl;
}
