#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <typename T>
inline bool remin(T& c, const T& n) {
  if (n < c) {
    c = n;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool remin2(T& c, const T& n) {
  if (c < 0 || n < c) {
    c = n;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool remax(T& c, const T& n) {
  if (c < n) {
    c = n;
    return 1;
  }
  return 0;
}
template <typename T>
inline void addmod(T& c, const T& n, const T& m) {
  c = (c + n) % m;
}
int _in;
int in() {
  scanf("%d", &_in);
  return _in;
}
pair<int, int> operator+(const pair<int, int>& a, const pair<int, int>& b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
const int N = 2e5 + 5;
int maj[N], from[N], to[N], jmpBegin[N], jmpEnd[N], tailBegin[N], tailEnd[N];
int main() {
  int i, j, c, n, m, k, total, ans = 0;
  memset(from, -1, sizeof(from));
  memset(to, -1, sizeof(to));
  memset(jmpBegin, -1, sizeof(jmpBegin));
  memset(jmpEnd, -1, sizeof(jmpEnd));
  memset(tailBegin, 0, sizeof(tailBegin));
  memset(tailEnd, 0, sizeof(tailEnd));
  scanf("%d%d%d", &n, &m, &k);
  for ((i) = (0); (i) < (n); ++(i)) maj[i] = in() - 1;
  for (i = 0; i < n; i = j) {
    for (c = maj[j = i]; j < n && c == maj[j]; ++j)
      ;
    if (from[c] >= 0 && to[c] >= 0) {
      jmpBegin[from[c]] = i;
      jmpEnd[to[c]] = j;
    }
    from[c] = i;
    to[c] = j;
    tailBegin[i] = j - i;
    tailEnd[j] = j - i;
  }
  memset(from, -1, sizeof(from));
  memset(to, -1, sizeof(to));
  for (i = 0; i < n; i = j) {
    for (c = maj[j = i]; j < n && c == maj[j]; ++j)
      ;
    if (from[c] < 0) {
      from[c] = i;
      to[c] = j;
    }
  }
  for ((c) = (0); (c) < (m); ++(c)) {
    i = from[c];
    j = to[c];
    if (i >= 0) {
      total = j - i;
      while (true) {
        if (total + k >= j - i) {
          remax(ans, total);
          j = jmpEnd[j];
          if (j < 0) break;
          total += tailEnd[j];
        } else {
          total -= tailBegin[i];
          i = jmpBegin[i];
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
