#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int a[maxn];
int main() {
  int n, m, k, res = 0, cnt = 0;
  long long sum = 0;
  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--) {
    if (sum + a[i] <= k)
      sum += a[i];
    else
      cnt++, sum = a[i];
    if (cnt == m) break;
    res++;
  }
  printf("%d\n", res);
  return 0;
}
