#include <bits/stdc++.h>
using namespace std;
long long int arr[10000000];
long long int b[10000000];
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  long long int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long int sum = 0;
  long long int num = 0;
  long long int p = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    sum += arr[i];
    if (sum > k) {
      sum = 0;
      i++;
      b[p] = num;
      p++;
      num = 0;
    } else if (i == 0) {
      num++;
      b[p] = num;
      p++;
      num = 0;
    } else {
      num++;
    }
  }
  for (int i = 0; i < m; i++) {
    cnt += b[i];
  }
  cout << cnt << endl;
  return 0;
}
