#include <bits/stdc++.h>
using namespace std;
const int N = 1e6, M = N, inf = (int)1e9;
const int mod = 1e9 + 7;
long long ans;
map<long long, long long> mp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long s = k;
  for (int i = n - 1; i >= 0; i--) {
    if (s >= v[i]) {
      s -= v[i];
      ans++;
    } else {
      m--;
      if (m == 0) break;
      s = k;
      s -= v[i];
      ans++;
    }
  }
  cout << ans;
}
