#include <bits/stdc++.h>
using namespace std;
const int M = 200 * 1000 + 11;
int main() {
  long long int n, m, k;
  scanf("%lld %lld %lld", &n, &m, &k);
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  reverse(a.begin(), a.end());
  int rem = 0;
  for (int i = 0; i < n; ++i) {
    if (rem - a[i] < 0) {
      if (m == 0) {
        cout << i << endl;
        return 0;
      } else {
        --m;
        rem = k - a[i];
      }
    } else {
      rem -= a[i];
    }
  }
  printf("%lld", n);
  return 0;
}
