#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int arr[a + 50];
  for (int i = 0; i < a; i++) cin >> arr[i];
  int cnt = 0, tmp = 0, ans = 0;
  for (int i = a - 1; i >= 0; i--) {
    if (tmp + arr[i] > c) {
      cnt++;
      tmp = 0;
      i++;
    } else {
      tmp += arr[i];
    }
    if (cnt == b) {
      ans = i;
      break;
    }
  }
  cout << a - ans << '\n';
  return 0;
}
