#include <bits/stdc++.h>
using namespace std;
int n, m, k, arr[200100];
vector<pair<int, int> > ranges[200100];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int l, r;
  l = r = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] != arr[i - 1]) {
      ranges[arr[i - 1]].push_back(pair<int, int>(l, r));
      l = r = i + 1;
    } else {
      r++;
    }
  }
  ranges[arr[n - 1]].push_back(pair<int, int>(l, r));
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < ranges[i].size(); j++) {
    }
  }
  int cost = 0, ans = 0;
  for (int i = 1; i <= m; i++) {
    if (ranges[i].size() < 1) continue;
    l = r = 0;
    cost = 0;
    int tmpans = ranges[i][0].second - ranges[i][0].first + 1;
    while (1) {
      if (cost <= k) {
        ans = max(tmpans, ans);
        r++;
        if (r == ranges[i].size()) break;
        cost += (ranges[i][r].first - ranges[i][r - 1].second - 1);
        tmpans += (ranges[i][r].second - ranges[i][r].first + 1);
      } else {
        l++;
        cost -= (ranges[i][l].first - ranges[i][l - 1].second - 1);
        tmpans -= (ranges[i][l - 1].second - ranges[i][l - 1].first + 1);
      }
    }
  }
  cout << ans << endl;
}
