#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  return f ? -x : x;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
const int N = 200000 + 10;
int ecnt, n, m, k, head[N], cur[N], q[N], ans = 1;
long long pre[N];
struct edge {
  int to, nxt;
} e[N];
void addedge(int u, int v) {
  e[++ecnt] = (edge){u, head[v]};
  head[v] = ecnt;
}
void dfs(int u, int dep) {
  if (dep > m) return;
  cur[dep] = u;
  ans = max(ans, cur[0] - u);
  for (int i = head[u]; i; i = e[i].nxt) {
    dfs(e[i].to, dep + 1);
  }
}
int main() {
  n = read(), m = read(), k = read();
  int h = 0, t = 0;
  for (int i = 1; i <= n; ++i) {
    pre[i] = pre[i - 1] + read();
    q[t++] = i;
    for (; h != t;) {
      if (pre[i] - pre[q[h] - 1] > k) {
        addedge(q[h++], i);
      } else {
        break;
      }
    }
  }
  for (; h != t;) addedge(q[h++], n + 1);
  dfs(n + 1, 0);
  write(ans);
  puts("");
}
