#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int suma = 0, ans = 0, count = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (suma + arr[i] <= k)
      suma = suma + arr[i];
    else {
      suma = arr[i];
      count += 1;
    }
    if (count >= m) break;
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}
