#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[1000002], i, j, l, r, p, ans = 1, d[1000002][5];
vector<vector<int> > v(200000);
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    v[a[i]].push_back(i);
  }
  for (i = 1; i <= m; i++) {
    l = r = 0;
    p = 0;
    for (j = 0; j < (int)v[i].size() - 1; j++) {
      d[r][0] = v[i][j];
      d[r][1] = v[i][j + 1];
      p += v[i][j + 1] - v[i][j] - 1;
      r++;
      while (l < r && p > k) {
        p -= d[l][1] - d[l][0] - 1;
        l++;
      }
      if (p <= k) {
        ans = max(ans, j + 1 - l + 1);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
