#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<long long> p(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    cin >> p[i];
    p[i] += p[i - 1];
  }
  long long ans = 0;
  long long dp[n + 2];
  memset(dp, 0xff, sizeof(dp));
  dp[n + 1] = 0;
  for (long long i = n; i >= 1; i--) {
    if (dp[i + 1] != -1) {
      long long idx = lower_bound(p.begin(), p.end(), p[i] - k) - p.begin();
      if (dp[i + 1] == m) continue;
      dp[idx + 1] = dp[i + 1] + 1;
    }
  }
  for (long long i = n + 1; i >= 1; i--)
    if (dp[i] != -1) ans = n + 1 - i;
  cout << ans;
  return 0;
}
