#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans = 0, now = 0, a[200005];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  m--;
  for (int i = n; i >= 1; i--) {
    if (now + a[i] > k) {
      if (a[i] <= k && m)
        m--, now = a[i], ans++;
      else
        return cout << ans, 0;
    } else
      now += a[i], ans++;
  }
  cout << ans;
  return 0;
}
