#include <bits/stdc++.h>
int n, m, k, ans = 0, cnt = 0;
int a[201000];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--) {
    cnt += a[i];
    if (cnt > k) {
      if (cnt == a[i]) printf("%d", n - i), exit(0);
      cnt = a[i];
      m--;
      if (m == 0) printf("%d", ans), exit(0);
    }
    ans++;
  }
  printf("%d", ans);
}
