#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int col[200005], num[200005], top;
int add[200005], last[100005];
vector<int> sum[100005], gap[200005];
int main() {
  int i, j;
  scanf("%d%d%d", &n, &m, &k);
  col[top = 0] = -1;
  for (i = 0; i < n; i++) {
    int c;
    scanf("%d", &c);
    if (c == col[top])
      num[top]++;
    else
      col[++top] = c, num[top] = 1;
  }
  add[0] = 0;
  for (i = 1; i <= top; i++) add[i] = add[i - 1] + num[i];
  for (i = 1; i <= top; i++) {
    if (sum[col[i]].empty()) {
      sum[col[i]].push_back(num[i]);
      gap[col[i]].push_back(0);
    } else {
      sum[col[i]].push_back(*(sum[col[i]].end() - 1) + num[i]);
      gap[col[i]].push_back(*(gap[col[i]].end() - 1) + add[i] - num[i] -
                            add[last[col[i]]]);
    }
    last[col[i]] = i;
  }
  int res = 0;
  for (i = 1; i <= m; i++)
    for (int u = 0; u < (int)gap[i].size(); u++) {
      int v = upper_bound(gap[i].begin(), gap[i].end(), gap[i][u] + k) - 1 -
              gap[i].begin();
      int tmp = sum[i][v] - sum[i][u] +
                (u == 0 ? sum[i][0] : sum[i][u] - sum[i][u - 1]);
      res = max(res, tmp);
    }
  printf("%d\n", res);
  return 0;
}
