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