#include <bits/stdc++.h>
using namespace std;
const long long N = (long long)2e5 + 5;
const long long mod = (long long)1e9 + 7;
const long long inf = (long long)1e18 + 7;
long long n, m, k;
vector<long long> A;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    A.push_back(x);
  }
  reverse(begin(A), end(A));
  long long rem = 0;
  for (long long i = 0; i < n; i++) {
    if (rem - A[i] < 0) {
      if (m == 0) {
        cout << i;
        return 0;
      } else {
        m--;
        rem = k - A[i];
      }
    } else
      rem -= A[i];
  }
  cout << n;
  return 0;
}
