#include <bits/stdc++.h>
using namespace std;
struct _ {
  _() { ios_base::sync_with_stdio(0); }
} _;
template <class A, class B>
ostream &operator<<(ostream &o, pair<A, B> t) {
  o << "(" << t.first << ", " << t.second << ")";
  return o;
}
template <class T>
void PV(T a, T b) {
  while (a != b) cout << *a++, cout << (a != b ? " " : "\n");
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
string tostring(T first, int len = 0) {
  stringstream ss;
  ss << first;
  string r = ss.str();
  if (r.length() < len) r = string(len - r.length(), '0') + r;
  return r;
}
template <class T>
void convert(string first, T &r) {
  stringstream ss(first);
  ss >> r;
}
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 2 * 111111;
int n, m, k;
int d[N];
vector<int> c[N];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    c[d[i]].push_back(i);
  }
  int res = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < c[i].size(); j++) {
      int L = j;
      int R = c[i].size() - 1;
      while (L < R) {
        int M = (L + R + 1) / 2;
        int cnt = (c[i][M] - c[i][j] + 1) - (M - j + 1);
        if (cnt <= k)
          L = M;
        else
          R = M - 1;
      }
      chmax(res, L - j + 1);
    }
  }
  cout << res << endl;
  return 0;
}
