#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i2 = pair<int, int>;
const int N = 2e5 + 9;
ll A[N];
int dp[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  ll k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> A[i];
  int j = n, res = 0;
  ll S = 0;
  for (int i = n; i >= 1; i--) {
    S += A[i];
    while (S > k) S -= A[j--];
    dp[i] = dp[j + 1] + 1;
    if (dp[i] <= m) res = max(res, n - i + 1);
  }
  cout << res;
  return 0;
}
