#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, in;
} arr[210000], qu[210000];
int n, m, k, ans, len;
int head, tail;
int cmp(node a, node b) {
  if (a.x == b.x)
    return a.in < b.in;
  else
    return a.x < b.x;
}
int main() {
  int i, j, tp;
  while (scanf("%d%d%d", &n, &m, &k) != EOF) {
    for (i = 1; i <= n; ++i) scanf("%d", &arr[i].x), arr[i].in = i;
    sort(arr + 1, arr + 1 + n, cmp);
    ans = 1, len = 0;
    head = 0, tail = 1;
    qu[++head] = arr[1];
    for (i = 2; i <= n; ++i) {
      if (arr[i].x != qu[head].x) {
        while (tail < head) tail++;
        len = head = 0;
        tail = 1;
        qu[++head] = arr[i];
      } else {
        tp = arr[i].in - qu[head].in - 1;
        if (tp + len > k) {
          while (tp + len > k && tail < head) {
            len -= qu[tail + 1].in - qu[tail].in - 1;
            tail++;
          }
          if (tail == head) len = 0;
        }
        len += tp;
        qu[++head] = arr[i];
      }
      if (head - tail + 1 > ans) ans = head - tail + 1;
    }
    printf("%d\n", ans);
  }
}
