#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
vector<int> v[maxn / 2];
int a[maxn];
int dp[maxn];
int n;
int m;
int k;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (dp[a[i]] == 0) {
      dp[a[i]] = i;
    } else {
      int u = i - dp[a[i]] - 1;
      v[a[i]].push_back(u);
      dp[a[i]] = i;
    }
  }
  int pes = 0;
  for (int i = 1; i <= m; i++) {
    int l = 0;
    int r = 1;
    int ans = 0;
    for (int j = 0; j < v[i].size(); j++) {
      ans += v[i][j];
      r++;
      if (ans > k) {
        pes = max(r - l - 1, pes);
        while (ans > k) {
          ans -= v[i][l];
          l++;
        }
      }
    }
    if (ans <= k) {
      pes = max(r - l, pes);
    }
  }
  cout << pes;
}
