#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int x;
  scanf("%d", &x);
  return x;
}
long long nextLong() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
double nextDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
const int BUFSIZE = 1000000;
char buf[BUFSIZE + 1];
string nextString() {
  scanf("%s", buf);
  return buf;
}
struct Point {
  double x, y;
  Point() : x(0), y(0) {}
  Point(double x, double y) : x(x), y(y) {}
  Point operator-(Point op) const { return Point(x - op.x, y - op.y); }
  Point operator+(Point op) const { return Point(x + op.x, y + op.y); }
  Point operator*(double op) const { return Point(x * op, y * op); }
  double operator*(Point op) const { return x * op.x + y * op.y; }
  double operator%(Point op) const { return x * op.y - y * op.x; }
  double length2() { return x * x + y * y; }
  double lengt() { return sqrt(length2()); }
};
Point nextPoint() {
  double x = nextDouble();
  double y = nextDouble();
  return Point(x, y);
}
struct Segment {
  int begin;
  int end;
  Segment(int b, int e) : begin(b), end(e) {}
  int len() { return end - begin; }
};
int FindMaxScore1(vector<Segment>& v, int k) {
  int res = 0;
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    int badSteps = k;
    int goodSteps = v[i].len();
    for (int r = i + 1; r < (int)v.size(); ++r) {
      int step = v[r].begin - v[r - 1].end;
      if (badSteps >= step) {
        badSteps -= step;
        goodSteps += v[r].len();
        res = max(res, goodSteps);
      } else
        break;
    }
  }
  return res;
}
int FindMaxScore(vector<Segment>& v, int k) {
  if (v.empty()) return 0;
  int res = 0;
  int badSteps = k;
  int goodSteps = v[0].len();
  int r = 0;
  for (int i = 0; i < (int)v.size(); ++i) {
    if (r < i) {
      r = i;
      badSteps = k;
      goodSteps = v[i].len();
    }
    for (; r < (int)v.size() - 1; ++r) {
      int step = v[r + 1].begin - v[r].end;
      if (badSteps >= step) {
        badSteps -= step;
        goodSteps += v[r + 1].len();
      } else
        break;
    }
    res = max(res, goodSteps);
    goodSteps -= v[i].len();
    if (r != i) {
      badSteps += v[i + 1].begin - v[i].end;
    }
  }
  return res;
}
int main() {
  int n = nextInt();
  int m = nextInt();
  int k = nextInt();
  vector<int> line;
  for (int i = 0; i < n; ++i) {
    line.push_back(nextInt() - 1);
  }
  int score = 0;
  vector<vector<Segment> > v(m);
  int begin = 0;
  for (int i = 0; i < n; ++i) {
    if (i == 0 || line[i - 1] != line[i]) {
      begin = i;
    }
    if (i == n - 1 || line[i] != line[i + 1]) {
      Segment s(begin, i + 1);
      v[line[i]].push_back(s);
      score = max(score, s.len());
    }
  }
  for (int i = 0; i < m; ++i) {
    score = max(score, FindMaxScore(v[i], k));
  }
  cout << score << endl;
  return 0;
}
