#include <bits/stdc++.h>
using namespace std;
int g[30], n, m, k, nxt[300005][30];
int p, a[300005], ans;
long long s[300005];
int main() {
  g[0] = 1;
  for (int i = 1; i <= 20; i++) g[i] = g[i - 1] * 2;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), s[i] = s[i - 1] + a[i];
  p = 0;
  for (int i = 1; i <= n; i++) {
    while (s[i] - s[p] > k) {
      nxt[p + 1][0] = i;
      p++;
    }
  }
  for (int i = p + 1; i <= n; i++) nxt[i][0] = n + 1;
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= 20; j++) nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
  }
  ans = 0;
  for (int i = 1; i <= n; i++) {
    int mm = m;
    int pos = i;
    for (int j = 20; j >= 0; j--)
      if (mm >= g[j]) {
        pos = nxt[pos][j];
        if (pos == 0) pos = n + 1;
        mm -= g[j];
      }
    ans = n + 1 - i;
    if (pos == n + 1) break;
  }
  printf("%d\n", ans);
}
