#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
int n, nbox, boxsz;
int a[MAXN];
long long sum[MAXN + 1];
int nxt[MAXN];
int need[MAXN + 1];
int solve() {
  sum[0] = 0;
  for (int i = (0); i < (n); ++i) sum[i + 1] = sum[i] + a[i];
  int to = 0;
  for (int at = (0); at < (n); ++at) {
    while (to < n && sum[to + 1] - sum[at] <= boxsz) ++to;
    nxt[at] = to;
  }
  need[n] = 0;
  for (int i = n - 1; i >= 0; --i) need[i] = 1 + need[nxt[i]];
  for (int i = (0); i <= (n); ++i)
    if (need[i] <= nbox) return n - i;
  return 0;
}
void run() {
  scanf("%d%d%d", &n, &nbox, &boxsz);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  printf("%d\n", solve());
}
int main() {
  run();
  return 0;
}
