#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
vector<pair<int, int>> mp[100005];
int gg(pair<int, int> p) { return p.second - p.first + 1; }
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int x, s = -1, l = -1;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    scanf("%d", &x);
    if (l == -1) {
      s = i;
      l = x;
    } else if (l != x) {
      mp[l].push_back({s, i - 1});
      s = i;
      l = x;
    }
  }
  mp[l].push_back({s, n - 1});
  int ans = 0;
  for (int i = 1; i <= m; i++)
    if (mp[i].size() > 0) {
      int t = gg(mp[i][0]);
      ans = max(ans, t);
      for (int l = 0, r = 1, dis = 0; r < mp[i].size();) {
        int tp = mp[i][r].first - mp[i][r - 1].second - 1;
        if (dis + tp <= k) {
          dis += tp;
          t += gg(mp[i][r]);
          ans = max(ans, t);
          r++;
        } else {
          if (r == l + 1) {
            t = gg(mp[i][r]);
            ans = max(ans, t);
            l = r;
            dis = 0;
            r++;
          } else {
            dis -= mp[i][l + 1].first - mp[i][l].second - 1;
            t -= gg(mp[i][l]);
            l++;
          }
        }
      }
    }
  printf("%d\n", ans);
  return 0;
}
