#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 1e9 + 7;
long long n, m, k, w;
int a[maxn];
vector<int> g[maxn];
int ans = 1;
inline void cal(int x) {
  int l = ans, r = g[x].size();
  int len = r;
  while (l <= r) {
    int mid = (l + r) >> 1;
    bool flag = 0;
    for (int i = 0; i + mid - 1 < len; i++) {
      int c = g[x][i + mid - 1] - g[x][i] - mid + 1;
      if (c <= k) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  ans = max(ans, r);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    g[a[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    cal(i);
  }
  cout << ans << endl;
  return 0;
}
