#include <bits/stdc++.h>
using namespace std;
long long sum[200001];
int main(int argc, char *argv[]) {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = n; i >= 1; --i) cin >> sum[i];
  for (int i = 2; i <= n; ++i) sum[i] += sum[i - 1];
  int ans = 0, pos = 1;
  while (pos <= n && m) {
    pos = upper_bound(sum + pos, sum + n + 1, sum[pos - 1] + k) - sum;
    --m;
  }
  cout << pos - 1 << endl;
  return 0;
}
