//采用队列,遍历str,求出队列的最长长度即可
import java.util.*;

public class Main {

public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in) ;
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int[] str = new int[n];
    for (int i = 0; i < n; i++) {
        str[i] = scanner.nextInt();
    }
    if ( str.length == 0) {
        System.out.println(0);
        return;
    }
    int num = 0;
    int max = 0;

    ArrayDeque<Integer> integers = new ArrayDeque<>();
    for (int i = 0; i < n; i++) {
        integers.offer(str[i]);
        if (str[i] ==0) {
            if (num < k) {
                num++;
            } else {
                while (integers.poll() != 0) {
                }
            }

        }
        max = Math.max(max, integers.size());

    }
    System.out.println(max);


}

}