#include <bits/stdc++.h>
using namespace std;
int items[200200];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> items[i];
  int ans = 0;
  while (m--) {
    int sum = 0;
    while (n >= 1 and k >= sum + items[n]) {
      sum += items[n--];
      ans++;
    }
  }
  cout << ans << endl;
}
