#include <bits/stdc++.h>
using namespace std;
vector<long long> nums[100001];
int main() {
  long long n, m, k;
  long long i, j;
  long long a;
  long long maxlen = 0;
  long long curlen;
  long long l, r;
  long long cursum;
  long long L;
  scanf("%I64d %I64d %I64d", &n, &m, &k);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a);
    nums[a].push_back(i);
  }
  for (i = 1; i <= m; i++) {
    L = nums[i].size();
    L--;
    for (j = 0; j < L; j++) {
      nums[i][j] = nums[i][j + 1] - nums[i][j] - 1;
    }
    if (nums[i].size() > 0) nums[i].pop_back();
  }
  for (i = 1; i <= m; i++) {
    l = 0;
    r = -1;
    cursum = 0;
    curlen = 0;
    for (j = 0; j < nums[i].size(); j++) {
      cursum = cursum + nums[i][j];
      r++;
      while (cursum > k) {
        cursum -= nums[i][l];
        l++;
      }
      if (r - l + 1 > curlen) curlen = r - l + 1;
    }
    if (curlen + 1 > maxlen) {
      maxlen = curlen + 1;
    }
  }
  printf("%I64d\n", maxlen);
  return 0;
}
