#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 200;
int f[N], cnt, Ans, sum, j;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> f[i], sum += f[i], cnt++;
    if (sum > m) sum -= f[j++], cnt--;
    Ans = max(Ans, cnt);
  }
  return cout << Ans << '\n', EXIT_SUCCESS;
}
