#include <bits/stdc++.h>
using namespace std;
int A[200000];
int main() {
  int n, i, m, k, number, capacity;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < n; ++i) scanf("%d", &A[i]);
  number = 0;
  i = n - 1;
  while (i >= 0 && A[i] <= k && m) {
    capacity = k;
    while (i >= 0 && capacity >= A[i]) {
      ++number;
      capacity -= A[i--];
    }
    --m;
  }
  printf("%d", number);
  return 0;
}
