#include <bits/stdc++.h>
using namespace std;
int a[2000000] = {0};
int main() {
  int n, m;
  int k;
  cin >> n >> m >> k;
  int *a = new int[n];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int i = n - 1;
  while (m > 0) {
    int size = k;
    while (size - a[i] >= 0 && i >= 0) {
      size -= a[i];
      i--;
      ans++;
    }
    m--;
  }
  cout << ans;
  return 0;
}
