#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\t';
  err(++it, args...);
}
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long INF = (1LL << 61);
const int inf = (1 << 30);
const int nn = 2e5 + 5;
int a[nn], n, m, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int box = 0, cnt = 0;
  for (int i = n - 1; i >= 0 && box < m;) {
    int cur = 0;
    while (i >= 0 && cur + a[i] <= k) {
      cur += a[i];
      cnt++;
      i--;
    }
    box++;
  }
  cout << cnt;
  return 0;
}
