#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
const int N = 2e5 + 5;
const long long int mod = 1e9 + 7;
const long long int Mod = 998244353;
const long double Pi = acos(-1);
const long long int Inf = 4e18;
int dx[9] = {0, 1, -1, 0, 0, 1, 1, -1, -1};
int dy[9] = {0, 0, 0, 1, -1, 1, -1, 1, -1};
using namespace std;
bool Check(vector<int> pos, int len, int k) {
  int rem = 0;
  for (int i = 1; i < len; i++) rem += pos[i] - pos[i - 1] - 1;
  if (rem <= k)
    return true;
  else {
    for (int i = 2; i < (int)pos.size(); i++) {
      if (i + len - 2 == (int)pos.size())
        break;
      else {
        rem -= (pos[i - 1] - pos[i - 2]);
        rem += (pos[i + len - 2] - pos[i + len - 3]);
        if (rem <= k) return true;
      }
    }
  }
  return false;
}
void TestCase() {
  int n, m, k, len = 0;
  cin >> n >> m >> k;
  vector<int> g[m + 1];
  for (int i = 1, x; i <= n; i++) {
    cin >> x;
    g[x].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    if ((int)g[i].size()) {
      int lb = 1, ub = (int)g[i].size(), mx = 1;
      while (lb <= ub) {
        int mid = (lb + ub) / 2;
        if (Check(g[i], mid, k)) {
          mx = max(mx, mid);
          lb = mid + 1;
        } else
          ub = mid - 1;
      }
      len = max(len, mx);
    }
  }
  cout << len;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int T = 1;
  while (T--) {
    TestCase();
    cout << "\n";
  }
  return 0;
}
