#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int l = 0, r = n - 1;
  int ans = INT_MAX;
  while (l <= r) {
    int mid = (l + r) >> 1;
    bool poss = true;
    long long sum = 0, ct = 1;
    for (int i = mid; i < n; i++) {
      if (sum + v[i] > k) {
        sum = v[i];
        ct++;
      } else {
        sum += v[i];
      }
    }
    if (ct <= m) {
      r = mid - 1;
      ans = min(ans, mid);
    } else
      l = mid + 1;
  }
  cout << n - ans << endl;
  return 0;
}
