#include using namespace std; int main() { int N, W; cin >> N >> W; vector A(N); for (int i = 0; i < N; i++) cin >> A.at(i); set SE; long ans = 0; for (long l = 0, r = 0, sum = 0; r < N; r++) { while (l < r && (SE.count(A.at(r)) || sum + A.at(r) > W)) SE.erase(A.at(l)), sum -= A.at(l), l++; SE.insert(A.at(r)), sum += A.at(r); if (sum <= W) ans = max(ans, r - l + 1); } cout << ans << "\n"; }