Harry Potter and the Goblet of Fire

5

1 votes
Medium, Medium
Problem

It's time for the Quidditch World Cup!

Everyone across the world wishes to attend it. So, for the convenience of the wizards, portkeys leading to the World Cup need to be placed in some cities so that they can attend it.

There are N cities in a line. Portkeys can only be placed in some of them, since, some cities have some muggle residents and the secrecy of the magical world cannot be given away. Now, a portkey in a city works only for wizards living in a city within a distance of K (< K) from it. And, as the Ministry of Magic wishes to have the least number of portkeys placed, find the minimum number of portkeys to be placed such that wizards from all cities can access them and attend the World Cup.

Input

First line contains two integers, N and K, the number of cities and the distance within which the portkeys work. Second line contains N integers, each either a 0 or a 1, where a 0 means a portkey cannot be placed in the ith city and 1 means a portkey can be placed in the ith city.

Output

Print in a single line the minimum number of portkeys required to allow the wizards in all the cities attend the World Cup. If it is not possible to have porkeys placed in such a manner, print -1.

Note

Distance between two cities, ci and cj is |i-j|.

Constraints

1<=K<=N<=10^5

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The portkeys can be placed in city 2 and 6, so that, cities 1,2,3 can access portkey in city 2 and cities 5,6,7 can access portkey in city 6, and city 4 can use either of them.

Editor Image

?