CSES - KILO 2017 5/5 - Zero Game
  • Time limit: 2.00 s
  • Memory limit: 512 MB

You are given one string S consisting of only 0 and 1. You are bored, so you start to play with the string. In each operation, you can move any character of this string to some other position in the string. For example, suppose S = 0010. Then you can move the first zero to the tail, and S will become 0100.

Additionally, you have q numbers k_1, k_2, \ldots , k_q. For each i, you wonder what can be the maximum number of consecutive zeroes in the string if you start with S and use at most k_i operations. In order to satisfy your curiosity, please write a program which will find the answers for you.

Input

The first line of input contains one string S. The second line of input contains one integer q. Each of the following q lines contains one integer k_i indicating the maximum number of operations in i-th query.

Output

For each query, output one line containing one number: the answer for this query.

Constraints

  • 2 \le |S| \le 10^6
  • 1 \le q \le 10^5
  • |S| \times q \le 2 \cdot 10^7
  • 1 \le k_i \le 10^6

Example

Input:

0000110000111110
5
1
2
3
4
5

Output:

5
8
9
9
9