#include <bits/stdc++.h>
using namespace std;
vector<int> V[300005];
long long n, m, j, k, i, l;
long long bas, son, mal;
long long x, mx = 1;
int main() {
  scanf("%lld %lld %lld", &n, &m, &k);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &x);
    V[x].push_back(i);
  }
  for (i = 1; i <= m; i++) {
    bas = 0;
    son = 0;
    mal = 0;
    for (j = 1; j < V[i].size(); j++) {
      while (mal + V[i][j] - V[i][j - 1] - 1 > k) {
        mal -= V[i][bas + 1] - V[i][bas] - 1;
        bas++;
      }
      if (mal + V[i][j] - V[i][j - 1] - 1 <= k) {
        son++;
        mx = max(mx, son - bas + 1);
        mal += V[i][j] - V[i][j - 1] - 1;
      }
    }
  }
  cout << mx;
  return 0;
}
