#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long a[100010]; int main() { long long n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } long long ans = 0; int right = 0; long long sum = 0; setst; int s = 0; for (int left = 0; left < n; left++) { while (right < n && !st.count(a[right]) && sum + a[right] <= k) { sum += a[right]; st.insert(a[right]); right++; } if (ans < right - left) { ans = right - left; } if (left == right) { right++; } else { st.erase(a[left]); sum -= a[left]; } } cout << ans << endl; }