#include <bits/stdc++.h>
const long long N = 2e5 + 5;
long long a[N];
long long dp[N];
long long psum[N];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  long long n, m, k;
  std::cin >> n >> m >> k >> a[0];
  psum[0] = a[0];
  for (long long i = 1; i < n; i++) {
    std::cin >> a[i];
    psum[i] = psum[i - 1] + a[i];
  }
  dp[n - 1] = 1;
  long long ans = n - 1;
  for (long long i = n - 2; i >= 0; i--) {
    long long l = i, h = n - 1;
    long long pos = l;
    while (l <= h) {
      long long m = (l + h) / 2;
      long long rsum = psum[m] - psum[i] + a[i];
      if (rsum > k) {
        h = m - 1;
      } else {
        pos = m;
        l = m + 1;
      }
    }
    dp[i] = 1 + ((pos == n - 1) ? 0 : dp[pos + 1]);
    if (dp[i] > m) {
      break;
    }
    ans = std::min(ans, i);
  }
  std::cout << n - ans << std::endl;
  return 0;
}
