#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, w, ans = 0; cin >> n >> w; vector a(n); for(auto &&v:a)cin >> v; set S; for(int l = 0, r = 0, s = 0; l < n; l++){ r = max(r, l); while(r < n && s + a[r] <= w && !S.count(a[r])){ S.insert(a[r]); s += a[r++]; ans = max(ans, r - l); } if(a[l] <= w){ S.erase(a[l]); s -= a[l]; } } cout << ans << '\n'; }