#include <bits/stdc++.h>
using namespace std;
int solve(int* a, int n, int k, int val) {
  int cnt = 0, k0 = 0;
  while (n--) {
    if (a[n] > k0) {
      k0 = k;
      if (++cnt > val) break;
    }
    k0 -= a[n];
  }
  return n + 1;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int* a = new int[n];
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  cout << n - solve(a, n, k, m) << '\n';
}
