#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int cur = k;
  int ans = 0;
  for (int i = (int)((a).size()) - 1; i >= 0; --i) {
    if (a[i] <= cur) {
      cur -= a[i];
    } else {
      --m;
      cur = k - a[i];
    }
    if (m == 0) break;
    ans++;
  }
  cout << ans;
  return 0;
}
