#include <bits/stdc++.h>   using namespace std;   long long a[201010];   int main() {     long long n, m, k;     while (~scanf( %lld%lld%lld , &n, &m, &k)) {       memset(a, 0, sizeof(a));       long long i, j, ans = 0, sum = k;       for (i = 1; i <= n; i++) scanf( %lld , &a[i]);       for (i = n; i >= 1; i--) {         if (a[i] > k) continue;         if (a[i] <= sum) {           sum -= a[i];           ans++;         } else {           m--;           if (m <= 0) break;           sum = k;           i++;         }       }       printf( %lld n , ans);     }     return 0;   }   