#include <bits/stdc++.h>
using namespace std;
long long n, m, k, a[300000], l, r, mid, ans, t, p;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = 2000000000;
  l = 1;
  r = n;
  while (l <= r) {
    mid = (l + r) / 2;
    ans = 0;
    t = 0;
    for (int i = mid; i <= n; i++) {
      ans += a[i];
      if (ans + a[i + 1] > k) {
        t++;
        ans = 0;
      }
    }
    if (t > m)
      l = mid + 1;
    else {
      p = mid;
      r = mid - 1;
    }
  }
  cout << n - p + 1;
}
