#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  auto check = [&](int num) {
    int res = 1;
    long long sum = 0;
    for (int i = n - num; i < n; i++) {
      sum += a[i];
      if (sum > k) {
        res++;
        sum = a[i];
      }
    }
    cerr << num << ' ' << res << '\n';
    return res <= m;
  };
  int l = 1, r = n + 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid;
  }
  cout << l - 1 << '\n';
  return 0;
}
