#include <bits/stdc++.h>
using namespace std;
const int N = 220000, M = 110000;
struct node {
  int l, r, c, next;
} a[N];
int tmp[M], n, m, k, h[M];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int f = 0, tot = 0, ans = 0;
  for (int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    if (x == f)
      a[tot].r = i;
    else {
      a[++tot] = (node){i, i, x, 0};
      if (h[x] == 0) {
        h[x] = tmp[x] = tot;
      } else {
        a[tmp[x]].next = tot;
        tmp[x] = tot;
      }
      f = x;
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (h[i] == 0) continue;
    int L = h[i], R = h[i], f = 0, sum = a[h[i]].r - a[h[i]].l + 1;
    for (; L; L = a[L].next) {
      for (; a[R].next and f + a[a[R].next].l - a[R].r - 1 <= k; R = a[R].next)
        f += a[a[R].next].l - a[R].r - 1,
            sum += a[a[R].next].r - a[a[R].next].l + 1;
      ans = max(ans, sum);
      sum -= a[L].r - a[L].l + 1;
      f -= a[a[L].next].l - a[L].r - 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
