#include <bits/stdc++.h>   using namespace std;   int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   const int N = 2e5 + 5;   long long a[N];   long long n, m, k;   bool check(int x) {     long long now = 0, cnt = 1;     for (int i = n - x + 1; i <= n; i++) {       if (now + a[i] > k) {         cnt++, now = a[i];       } else         now += a[i];     }     return cnt <= m;   }   int upp(int l, int r) {     while (l < r) {       int mid = (l + r + 1) >> 1;       if (check(mid))         l = mid;       else         r = mid - 1;     }     return l;   }   int main() {     n = read(), m = read(), k = read();     for (int i = 1; i <= n; i++) a[i] = read();     printf( %d n , upp(1, n));     return 0;   }   