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