#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[500005], dd[500005];
vector<int> p[500005];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i], p[a[i]].push_back(i);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    dd[a[i]]++;
    int l = dd[a[i]] - 1, r = p[a[i]].size();
    while (r - l > 1) {
      int mid = (r + l) >> 1;
      int x = p[a[i]][mid] - i - 1 - (mid - dd[a[i]]);
      if (x <= k)
        l = mid;
      else
        r = mid;
    }
    ans = max(ans, l - (dd[a[i]] - 1) + 1);
  }
  cout << ans;
}
