#include <bits/stdc++.h>
using namespace std;
bool prime[10000 + 1];
void sieve() {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= 10000; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= 10000; i += p) prime[i] = false;
    }
  }
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long pow(int v, int a) {
  long prod = 1;
  for (int i = 0; i < a; i++) prod *= v;
  return prod;
}
int n, m, k;
std::vector<int> v[100001];
bool ok(int val) {
  val--;
  for (int i = 1; i < m + 1; i++) {
    if (v[i].size() >= val) {
      if (v[i][val - 1] <= k) {
        return 1;
      }
      int j = val;
      while (j < v[i].size()) {
        if (v[i][j] - v[i][j - val] <= k) {
          return 1;
        } else
          j++;
      }
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  int a;
  for (int i = 1; i < n + 1; i++) {
    cin >> a;
    if (v[a].empty())
      v[a].push_back(i);
    else {
      auto it = v[a].rbegin();
      *it = abs(*it - i) - 1;
      v[a].push_back(i);
    }
  }
  for (int i = 0; i < m + 1; i++) {
    if (!v[i].empty()) {
      v[i].erase(v[i].end() - 1);
      for (int j = 1; j < v[i].size(); j++) v[i][j] += v[i][j - 1];
    }
  }
  long l = 2, r = n, mid, ans = 1;
  while (l <= r) {
    mid = l + (r - l) / 2;
    if (ok(mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << ans;
  return 0;
}
