#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  for (int i = 0; i < N; i++) cin >> a[i];
  int sum = 0, cnt = 1, i;
  for (i = N - 1; i >= 0; i--) {
    if (sum + a[i] > K) {
      cnt++;
      if (cnt > M) {
        cout << N - i - 1 << endl;
        return 0;
      }
      sum = 0;
    }
    sum += a[i];
  }
  cout << N << endl;
}
