#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k, col, tk, u = 0;
  cin >> n >> m >> k;
  col = m;
  tk = k;
  vector<long long> a(n);
  for (long long j = 0; j < n; j++) {
    cin >> a[j];
  }
  for (long long j = n - 1; j >= 0; j--) {
    if (col > 0) {
      if (tk >= a[j]) {
        tk = tk - a[j];
        u += 1;
      } else {
        col = col - 1;
        tk = k;
        if ((tk >= a[j]) && (col > 0)) {
          tk = tk - a[j];
          u += 1;
        }
      }
    }
  }
  cout << u;
}
