#include <bits/stdc++.h>
using namespace std;
int n, m, k, f[200005], maxx = -100, c[200005];
deque<int> b[200005];
int main() {
  ios_base::sync_with_stdio(0);
  int x;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (!b[x].empty())
      b[x].push_back(i - f[x] - 1);
    else
      b[x].push_back(0);
    f[x] = i;
  }
  for (int i = 1; i <= m; i++) {
    int g = 0, z;
    while (!b[i].empty()) {
      z = b[i].front();
      b[i].pop_front();
      g++;
      f[g] = z;
      c[g] = c[g - 1] + z;
    }
    int maxtuyi = -1;
    int p1 = 1, p2 = 1;
    while (p2 < g) {
      if (c[p2 + 1] - c[p1] <= k) {
        p2++;
        maxtuyi = max(maxtuyi, p2 - p1 + 1);
      } else
        p1++;
    }
    maxtuyi = max(maxtuyi, p2 - p1 + 1);
    maxx = max(maxx, maxtuyi);
  }
  cout << maxx;
  return 0;
}
