#include <bits/stdc++.h>
using namespace std;
int search(long long val, long long dp[], int low, int high) {
  int mid = (low + high) / 2;
  if (dp[mid] == val) {
    return mid + 1;
  } else if (dp[mid] < val) {
    if (mid == high || dp[mid + 1] > val) {
      return mid + 1;
    }
    return search(val, dp, mid + 1, high);
  } else {
    if (dp[mid - 1] <= val) {
      return mid;
    }
    return search(val, dp, low, mid - 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  long long arr[n + 1];
  long long index = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] > k) {
      index = i;
    }
  }
  long long rem = index;
  int z = n - rem;
  long long dp[z + 1];
  dp[0] = 0;
  for (int i = index + 1; i <= n; i++) {
    dp[i - index] = arr[i] + dp[i - index - 1];
  }
  int low = 1, high = z;
  while (low < high) {
    int box = m;
    int mid = (low + high) / 2;
    int start = mid;
    while (mid <= z && box) {
      mid = search(dp[mid - 1] + k, dp, mid, z);
      box--;
    }
    if (mid <= z) {
      low = start + 1;
    } else {
      if (start == low) {
        cout << n - (rem + low - 1);
        return 0;
      }
      high = start;
    }
  }
  cout << n - (rem + low - 1);
}
