#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int n, k;
void solve() {
  cin >> n >> k;
  vector<long long int> arr(n);
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  long long int sum = 0, cnt = 0, read = 0, ptr = 0;
  vector<long long int> nalasupari;
  for (long long int i = 0; i < n; i++) {
    if (sum + arr[i] <= k)
      sum += arr[i], nalasupari.emplace_back(arr[i]), cnt++;
    else {
      read = max(read, cnt);
      sum += arr[i];
      cnt++;
      nalasupari.emplace_back(arr[i]);
      while (sum > k and ptr < nalasupari.size())
        sum -= nalasupari[ptr++], cnt--;
    }
  }
  read = max(cnt, read);
  cout << read;
}
int32_t main() { solve(); }
