#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int N = 2e5 + 5;
const int INF = 2e9;
const lint LINF = 9e18;
const int MOD = 1e9 + 7;
int n, m, k;
int a[N];
vector<int> pos[N >> 1];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  set<int> ada;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]].emplace_back(i);
    ada.emplace(a[i]);
  }
  int ans = 0;
  for (int i : ada) {
    for (int j = 0; j < pos[i].size() - 1; j++) {
      const auto BS = [&](int l, int r) {
        const auto valid = [&](int M) {
          return (pos[i][M] - pos[i][j]) - (M - j) <= k;
        };
        pair<int, int> ret = {-1, -1};
        while (l <= r) {
          int mid = l + r >> 1;
          if (valid(mid)) {
            ret.first = mid;
            ret.second = (pos[i][mid] - pos[i][j]) - (mid - j);
            l = mid + 1;
          } else {
            r = mid - 1;
          }
        }
        return ret;
      };
      pair<int, int> temp = BS(j + 1, pos[i].size() - 1);
      if (temp.first == -1) {
        continue;
      } else {
        ans = max(ans, pos[i][temp.first] - pos[i][j] + 1 - temp.second);
      }
    }
    ans = max(ans, 1);
  }
  cout << ans << "\n";
}
