#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
long long a[200005];
long long pre[200005];
int main() {
  int n, m;
  long long k;
  scanf("%d%d%lld", &n, &m, &k);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    pre[i] = pre[i - 1] + a[i];
  }
  int r = n;
  for (int i = 1; i <= m; i++) {
    r = lower_bound(pre, pre + 1 + n, pre[r] - k) - pre;
  }
  ans = n - r;
  printf("%lld\n", ans);
  return 0;
}
