#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> nums(n);
  for (int i = 0; i < n; ++i) {
    cin >> nums[i];
    --nums[i];
  }
  vector<int> st(m, -1);
  vector<int> list(n, -1);
  st[nums[0]] = 0;
  vector<int> w(n, 0);
  w[0] = 1;
  for (int i = 1; i < n; ++i) {
    if (nums[i] == nums[i - 1])
      w[st[nums[i]]]++;
    else {
      list[i] = st[nums[i]];
      w[i]++;
      st[nums[i]] = i;
    }
  }
  int ans = 1;
  for (int i = 0; i < m; ++i) {
    if (st[i] != -1) {
      int left = st[i];
      int len = k;
      int cur_w = w[st[i]];
      int right = st[i];
      while (right != -1) {
        while (len < 0) {
          cur_w -= w[left];
          int t = list[left];
          len += abs(left - (t + w[t]));
          left = t;
        }
        ans = max(ans, cur_w);
        int t = list[right];
        if (t != -1) {
          len -= (right - (t + w[t]));
          cur_w += w[t];
        }
        right = t;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
