#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int main() {
  cin >> n >> m >> k;
  vector<int> siz(n, 0);
  for (int i = 0; i < n; ++i) cin >> siz[i];
  int it = n - 1;
  int cc = 0;
  int boxFilled = 0;
  for (; it >= 0;) {
    if (siz[it] > k or boxFilled == m)
      break;
    else {
      if ((k - cc) < siz[it]) {
        ++boxFilled;
        cc = 0;
      } else {
        cc += siz[it];
        --it;
      }
    }
  }
  cout << ((n - 1) - it) << endl;
}
