#include <bits/stdc++.h>
using namespace std;
int a[200009];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int tmp = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (tmp + a[i] <= k) {
      tmp += a[i];
    } else {
      m--;
      tmp = a[i];
      if (m == 0) {
        cout << n - 1 - i << endl;
        return 0;
      }
    }
  }
  cout << n << endl;
  return 0;
}
