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