#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], n, m, k;
vector<pair<int, int> > p[N];
vector<int> r[N];
int ans;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n;) {
    int r = i + 1;
    while (r < n && a[i] == a[r]) r++;
    p[a[i]].push_back(make_pair(i, r - 1));
    i = r;
  }
  for (int i = 1; i <= m; i++) {
    if (p[i].size() == 1)
      ans = max(ans, p[i][0].second - p[i][0].first + 1);
    else {
      for (int j = 1; j < (int)p[i].size(); j++)
        r[i].push_back(p[i][j].first - p[i][j - 1].second - 1);
      int s = r[i].size();
      int t = 0, sum = 0;
      for (int j = 0; t < s && j < s; j++) {
        t = max(t, j);
        while (t < s && r[i][t] + sum <= k) {
          t++;
          sum += r[i][t - 1];
          ans = max(ans, p[i][t].second - p[i][j].first + 1 - sum);
        }
        if (t > j) sum -= r[i][j];
      }
    }
  }
  cout << ans;
  return 0;
}
