#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first - a.second) > (b.first - b.second);
}
long long int power(long long int x, long long int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
long long int power_mod(long long int b, long long int e, long long int m) {
  long long int a = 1;
  while (e != 0) {
    if ((e & 1) == 1) a = (a * b) % m;
    b = (b * b) % m;
    e >>= 1;
  }
  return a % m;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  deque<int> v;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  long long int sm = 0;
  int nxt[200005] = {0};
  int wor = 0;
  reverse(v.begin(), v.end());
  for (int i = 0; i < n; ++i) {
    sm += v[i];
    if (sm == k) {
      m--;
      if (m == 0) {
        cout << (i + 1) << endl;
        return 0;
      }
      sm = 0;
    } else if (sm > k) {
      m--;
      i--;
      if (m == 0) {
        cout << (i + 1) << endl;
        return 0;
      }
      sm = 0;
    }
  }
  cout << n << endl;
  return 0;
}
