#include <bits/stdc++.h>
using namespace std;
long long x, y, z, a;
deque<long long> q;
bool b = 1;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> x >> y >> z;
  for (int i = 0; i < x; i++) {
    cin >> a;
    q.push_back(a);
  }
  long long ans = 0, s = 0, ss = x - 1;
  while (s < y && ss >= 0) {
    long long sum = z;
    b = 1;
    while (ss >= 0 && sum >= q[ss]) {
      sum -= q[ss--], ans++, b = 0;
    }
    if (b) {
      cout << ans << endl;
      return 0;
    }
    s++;
  }
  cout << ans << endl;
  return 0;
}
