#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int a[N], n, m, k;
int check(int x) {
  int cnt = 1, space = k;
  for (int i = x; i < n; i++) {
    if (a[i] <= space)
      space -= a[i];
    else {
      if (cnt == m) return 0;
      ++cnt, space = k - a[i];
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int l = 0, r = n - 1, mid;
  while (l != r) {
    mid = (l + r) / 2;
    check(mid) ? r = mid : l = mid + 1;
  }
  cout << n - l << '\n';
  return 0;
}
