#include <bits/stdc++.h>
using namespace std;
void solve() {}
const long long maxn = 200500;
const long long maxm = 100500;
long long n, m, k;
long long a[maxn];
vector<long long> inds[maxm];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    inds[a[i]].emplace_back(i);
  }
  long long ans = 0;
  for (long long c = 1; c <= m; c++) {
    if (false) cerr << "on color " << c << '\n';
    for (long long x : inds[c]) {
      if (false) cerr << x << " ";
    }
    if (false) cerr << '\n';
    long long l = 0, r = 0;
    long long cost = 0;
    while (l < (long long)inds[c].size()) {
      while (r + 1 < (long long)inds[c].size()) {
        if (cost + inds[c][r + 1] - inds[c][r] - 1 <= k) {
          cost += inds[c][r + 1] - inds[c][r] - 1;
          r++;
        } else
          break;
      }
      if (false)
        cerr << "l is " << inds[c][l] << " and we can go up to " << inds[c][r]
             << '\n';
      if (false) cerr << ("cost") << " is " << (cost) << '\n';
      ans = max(ans, inds[c][r] - inds[c][l] + 1 - cost);
      if (l + 1 < (long long)inds[c].size()) {
        cost -= inds[c][l + 1] - inds[c][l] - 1;
      }
      l++;
    }
  }
  cout << ans << '\n';
}
