#include <bits/stdc++.h>
const double EPS = 0.0000000001;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 7;
const long long mod3 = 1e9 + 9;
const long long mod4 = 228228227;
const long long inf = 1e16;
using namespace std;
void print(vector<long long>& v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] + 1 << " ";
}
signed main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long mass[n];
  for (long long i = 0; i < n; i++) cin >> mass[i];
  long long res[a];
  for (long long i = 0; i < a; i++) res[i] = b;
  long long x = n - 1;
  long long y = a - 1;
  long long c = 0;
  while (x >= 0 && y >= 0) {
    if ((res[y] - mass[x]) >= 0) {
      c++;
      res[y] -= mass[x];
      x--;
      continue;
    }
    y--;
  }
  cout << c;
}
