#include <bits/stdc++.h>
using namespace std;
const int maxm = 2e6 + 5;
int a[maxm * 2];
vector<int> v[maxm];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    v[a[i]].push_back(i);
  }
  int maxn = 1;
  for (int i = 1; i <= m; i++) {
    int L = 0, R = 0, cnt = k, ans = 1;
    while (1) {
      int len = v[i].size();
      while (R < len - 1) {
        if (cnt - (v[i][R + 1] - v[i][R] - 1) >= 0) {
          ans++;
          cnt -= (v[i][R + 1] - v[i][R] - 1);
          maxn = max(maxn, ans);
          R++;
        } else
          break;
      }
      if (R >= len - 1) {
        break;
      }
      L++;
      cnt += (v[i][L] - v[i][L - 1] - 1);
      ans--;
    }
  }
  cout << maxn << endl;
  return 0;
}
