#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int rmq[N][19], n, m, k, v[N];
void precalc_rmq() {
  int sum(0);
  for (int i = 1; i <= n; ++i) {
    sum += v[i];
    if (sum + v[i + 1] > k) {
      rmq[1][0] = i;
      break;
    }
  }
  if (rmq[1][0] == 0) rmq[1][0] = n;
  for (int i = 2; i <= n; ++i) {
    sum -= v[i - 1];
    int j;
    for (j = rmq[i - 1][0] + 1; sum + v[j] <= k && j <= n; ++j) sum += v[j];
    rmq[i][0] = j - 1;
  }
  for (int p = 1; (1 << p) <= n; ++p) {
    for (int i = 1; i <= n; ++i) {
      if (rmq[i][p - 1] == n)
        rmq[i][p] = n;
      else
        rmq[i][p] = rmq[rmq[i][p - 1] + 1][p - 1];
    }
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) cin >> v[i];
  precalc_rmq();
  for (int i = 1; i <= n; ++i) {
    int ans = i - 1;
    for (int j = 0; (1 << j) <= m; ++j)
      if (m & (1 << j)) ans = rmq[ans + 1][j];
    if (ans == n) return cout << n - i + 1, 0;
  }
  return 0;
}
