#include <bits/stdc++.h>
using namespace std;
vector<long long int> arr(200005), dp(200005), dp1(200005);
vector<long long int> ans(100005), start(100005), curr(100005);
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  fill(ans.begin(), ans.end(), -1);
  for (long long int i = n - 1; i >= 0; i--) {
    if (ans[arr[i]] == -1) {
      dp[i] = i;
      ans[arr[i]] = i;
    } else {
      dp[i] = ans[arr[i]];
      ans[arr[i]] = i;
    }
  }
  fill(ans.begin(), ans.end(), -1);
  for (long long int i = 0; i < n; i++) {
    if (ans[arr[i]] == -1) {
      dp1[i] = i;
      ans[arr[i]] = i;
    } else {
      dp1[i] = ans[arr[i]];
      ans[arr[i]] = i;
    }
  }
  fill(ans.begin(), ans.end(), -1);
  for (long long int i = 0; i < n; i++) {
    if (ans[arr[i]] == -1) {
      ans[arr[i]] = 1;
      curr[arr[i]] = 1;
      start[arr[i]] = i;
    } else {
      long long int temp = i - dp1[i] - 1;
      long long int temp1 = curr[arr[i]];
      for (long long int j = start[arr[i]];; j = start[arr[i]]) {
        if (k < i - start[arr[i]] - temp1) {
          start[arr[i]] = dp[start[arr[i]]];
          temp1--;
        } else {
          ans[arr[i]] = max(ans[arr[i]], temp1 + 1);
          curr[arr[i]] = temp1 + 1;
          break;
        }
      }
    }
  }
  long long int ans1 = 1;
  for (long long int i = 1; i <= m; i++) {
    ans1 = max(ans1, ans[i]);
  }
  cout << ans1 << "\n";
}
