#include <bits/stdc++.h>
using namespace std;
long long a[1001000];
int main() {
  long long n, m, k, bx = 1, it = 0, ans = 1;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = n; i >= 1; i--) {
    if ((it + a[i]) > k) {
      if (bx == m) {
        ans = i + 1;
        break;
      }
      it = a[i];
      bx++;
    } else
      it += a[i];
  }
  cout << (n - ans + 1) << endl;
}
