#include <bits/stdc++.h>
using namespace std;
int II() {
  int q;
  scanf("%d", &q);
  return q;
}
const int Mx = 200005;
int ar[Mx];
int N, M, K;
bool BS(int mid) {
  int ans = 1, mot = K;
  for (int i = mid; i <= N; i++) {
    if ((mot >= ar[i])) {
      mot -= ar[i];
    } else {
      ans++;
      mot = K - ar[i];
    }
  }
  return ans <= M;
}
void solve() {
  cin >> N >> M >> K;
  for (int i = 1; i <= N; i++) cin >> ar[i];
  int l = 1, r = N;
  int re = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (BS(mid)) {
      re = N - mid + 1;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  cout << re << endl;
}
int main() {
  int tt;
  tt = 1;
  int cas = 1;
  while (tt--) {
    solve();
  }
}
