#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
long long MOD = 1e9 + 7;
const char nl = '\n';
const long long inf = 1e15;
long long power(long long x, long long y) {
  long long z = 1;
  while (y > 0) {
    if (y % 2) z = z * x;
    x = x * x;
    y /= 2;
  }
  return z;
}
long long gcd(long long a, long long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long sq(long long a) {
  long long ans = (1ll * a * a);
  return ans;
}
long long bigmod(long long a, long long p) {
  long long res = 1;
  long long x = a % MOD;
  while (p) {
    if (p & 1) {
      res = (res * x) % MOD;
    }
    x = (x * x) % MOD;
    p >>= 1;
  }
  return res;
}
vector<vector<int>> c(100001);
map<pair<int, int>, int> mr;
int binary_search(int target, int i) {
  if (mr.find({target, i}) != mr.end()) {
    return mr[{target, i}];
  }
  vector<int> v = c[i];
  int n = v.size();
  int l = 0;
  int r = n - 1;
  int ans;
  while (l <= r) {
    int mid = (r + l) / 2;
    if (v[mid] >= target) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  mr[{target, i}] = ans;
  return ans;
}
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans[n];
  int cost[n];
  unordered_map<int, int> map;
  ans[0] = 1;
  cost[0] = 0;
  map[a[0]] = 0;
  for (int i = 1; i < n; i++) {
    if (map.find(a[i]) == map.end()) {
      ans[i] = 1;
      cost[i] = 0;
      map[a[i]] = i;
    } else {
      ans[i] = 1 + ans[map[a[i]]];
      cost[i] = i - map[a[i]] - 1 + cost[map[a[i]]];
      map[a[i]] = i;
    }
  }
  int result = 0;
  vector<vector<int>> g(m + 1);
  for (long long i = 0; i < n; i++) {
    g[a[i]].push_back(ans[i]);
    c[a[i]].push_back(cost[i]);
  }
  for (int i = 1; i <= m; i++) {
    for (long long j = 0; j < c[i].size(); j++) {
      if (c[i][j] <= k) {
        result = max(result, g[i][j]);
      } else {
        int temp = c[i][j] - k;
        int idx = binary_search(temp, i);
        result = max(result, g[i][j] - g[i][idx] + 1);
      }
    }
  }
  cout << result << nl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long TC = 1;
  while (TC--) {
    solve();
  }
}
