#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int arr[m];
  fill(arr, arr + m, k);
  int cnt = n;
  int darr[n];
  for (int i = 0; i < n; i++) {
    cin >> darr[i];
  }
  int j = 0;
  for (int i = n - 1; i >= 0; i--) {
    int stat = 1;
    if (arr[j] >= darr[i]) {
      arr[j] -= darr[i];
    } else if (j != m - 1) {
      j++;
      arr[j] -= darr[i];
    } else {
      cnt = n - (i + 1);
      break;
    }
  }
  cout << cnt;
  return 0;
}
