A train has n cabins arranged in a line. Some cabins are occupied by passengers, and some are empty.
You are given an array cabins of length n where:
-
cabinsi=1 if cabin i has a passenger,
-
cabinsi=0 if it is empty.
Passengers can switch places with passengers in adjacent cabins in one move.
For example, in [1,0,0,1,0,1] with k=2, moving the 4th passenger one step
to the right gives two consecutive passengers in 1 move.
Your task is to compute the minimum number of moves required so that k passengers end up sitting in
k consecutive cabins.
>
The first line contains two integers n and k
(1≤k≤n≤105) — the number of cabins and the number of passengers to be grouped together.
The second line contains n integers cabins1,cabins2,…,cabinsn
(cabinsi∈{0,1}) — the occupancy state of each cabin.
It is guaranteed that the array contains at least k passengers in total.
>
Print the minimum number of moves required so that there exists a group of k passengers sitting together in k consecutive cabins.