#include <bits/stdc++.h>
using namespace std;
int solve() {
  long long int n, m, k;
  cin >> n >> m >> k;
  vector<long long int> v(n);
  for (auto &i : v) cin >> i;
  reverse(v.begin(), v.end());
  long long int cnt = 0;
  std::vector<long long int> sz(m, k);
  long long int j = 0;
  for (long long int i = 0; i < n; i++) {
    if (j < m) {
      if (v[i] <= sz[j]) {
        sz[j] -= v[i];
        cnt++;
      } else {
        j++;
        i--;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
int main() {
  long long int t = 1;
  while (t--) solve();
  return 0;
}
