#include <bits/stdc++.h>
using namespace std;
const int oo = 1e8, mod = (1e9 + 7) * 0 + 998244353 * 1;
const double PI = acos(-1), EPS = 1e-8;
int dr[]{-1, 1, 0, 0, 1, 1, -1, -1};
int dc[]{0, 0, 1, -1, 1, -1, 1, -1};
void run() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
vector<long long> v;
int n, m, k;
int BS(int st, long long x) {
  int ed = n, md, ans = st;
  while (st <= ed) {
    md = (st + ed) / 2;
    if (v[md] <= x)
      st = md + 1, ans = md;
    else
      ed = md - 1;
  }
  return ans;
}
bool ok(int st) {
  for (int i = st; i <= n; i++) v[i] -= v[st - 1];
  int cnt = 0, i = BS(st, k);
  while (i <= n) {
    i = BS(i + 1, v[i] + k);
    cnt++;
  }
  for (int i = st; i <= n; i++) v[i] += v[st - 1];
  return (cnt <= m);
}
int main() {
  run();
  cin >> n >> m >> k;
  v = vector<long long>(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    v[i] += v[i - 1];
  }
  int st = 1, ed = n, md, ans = n;
  while (st <= ed) {
    md = (st + ed) / 2;
    if (ok(md))
      ed = md - 1, ans = md;
    else
      st = md + 1;
  }
  return cout << n - ans + 1, 0;
}
