#include <bits/stdc++.h>
using namespace std;
vector<int> inf[1015];
vector<int> arr[1015];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int id = 0;
  vector<int> t(m);
  int x = 0;
  for (int i = 0; i < n; i++) {
    int nt;
    scanf("%d", &nt);
    nt--;
    x++;
    arr[id].push_back(nt);
    t[nt]++;
    if (x >= 384) {
      x = 0;
      inf[id] = t;
      t = vector<int>(m);
      id++;
    }
  }
  if (x > 0) {
    x = 0;
    inf[id] = t;
    id++;
  }
  int nid = 0;
  int anw = 0;
  for (int i = 0; i < n; i++) {
    int tk = k;
    int ts = 0;
    for (int j = x; j < arr[nid].size(); j++) {
      if (arr[nid][j] != arr[nid][x])
        tk--;
      else
        ts++;
      if (tk < 0) break;
    }
    if (tk >= 0) {
      for (int j = nid + 1; j < id; j++) {
        int lk = int(arr[j].size()) - inf[j][arr[nid][x]];
        if (tk - lk < 0) {
          for (int k = 0; k < arr[j].size(); k++) {
            if (arr[j][k] != arr[nid][x])
              tk--;
            else
              ts++;
            if (tk < 0) break;
          }
          break;
        } else {
          tk -= lk;
          ts += inf[j][arr[nid][x]];
        }
      }
    }
    x++;
    if (x >= 384) {
      x = 0;
      nid++;
    }
    anw = max(anw, ts);
  }
  printf("%d", anw);
}
