#include <bits/stdc++.h>
using namespace std;
vector<long long int> A(200010), dp(200010);
long long int n, c, s, ans = 0;
bool is_possible(long long int m) {
  long long int i = n - m + 1, count = 0;
  while (i <= n) {
    long long int sum = 0;
    while (i <= n && sum + A[i] <= s) {
      sum += A[i];
      i++;
    }
    count++;
  }
  return count <= c;
}
void b_search(long long int l, long long int r) {
  if (l <= r) {
    long long int m = (l + r) / 2;
    if (is_possible(m)) {
      ans = max(ans, m);
      l = m + 1;
    } else {
      r = m - 1;
    }
    b_search(l, r);
  }
}
int main() {
  cin >> n >> c >> s;
  for (long long int i = 1; i <= n; i++) {
    cin >> A[i];
    dp[i] = dp[i - 1] + A[i];
  }
  b_search(0, n);
  cout << ans << endl;
}
