#include using namespace std; int main(){ int n, w; cin >> n >> w; assert(1 <= n); assert(n <= 100000); assert(0 <= w); assert(w <= 1000000000); vector a(n); for (int i = 0; i < n; i++){ cin >> a[i]; assert(0 <= a[i]); assert(a[i] <= 1000000000); } int ans = 0; int sum = 0; map mp; int R = 0; for (int L = 0; L < n; L++){ while (R < n){ if (sum + a[R] <= w && mp[a[R]] == 0){ sum += a[R]; mp[a[R]]++; R++; } else { break; } } ans = max(ans, R - L); if (R == L){ sum += a[R]; mp[a[R]]++; R++; } sum -= a[L]; mp[a[L]]--; } cout << ans << endl; }