#include <bits/stdc++.h>
using namespace std;
const long long maxN = 200000 + 9;
long long a[maxN];
long long n, m, k;
bool judge(int x) {
  int res = 1;
  int tmp = k;
  for (int i = x; i <= n; i++) {
    if (tmp >= a[i])
      tmp -= a[i];
    else {
      tmp = k - a[i];
      res++;
    }
  }
  return res <= m;
}
int main() {
  scanf("%lld %lld %lld", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  int l = 1, r = n;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (judge(mid))
      r = mid;
    else
      l = mid;
  }
  if (judge(l))
    printf("%d\n", n - l + 1);
  else
    printf("%d\n", n - r + 1);
  return 0;
}
