import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int w = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } HashSet set = new HashSet<>(); int left = 0; int right = -1; int sum = 0; int max = 0; while (right < n - 1) { while (right < n - 1 && !set.contains(arr[right + 1]) && sum + arr[right + 1] <= w) { right++; set.add(arr[right]); sum += arr[right]; } max = Math.max(max, right - left + 1); set.remove(arr[left]); sum -= arr[left]; left++; if (left > right) { right = left - 1; sum = 0; } } System.out.println(max); } }