Zero Game

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

You are given one string SS 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‘’S = \text{'`0010`'}. Then you can move the first zero to the tail, and SS will become '0100'.

Additionally, you have QQ numbers K_1,K_2,,K_QK\_1, K\_2, \ldots, K\_Q. For each ii, you wonder what can be the maximum number of consecutive zeroes in the string if you start with SS and use at most K_iK\_i operations. In order to satisfy your curiosity, please write a program which will find the answers for you.

입력

The first line of input contains one string SS. The second line of input contains one integer QQ. Each of the following QQ lines contains one integer K_iK\_i indicating the maximum number of operations in ii-th query.

출력

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

제한

  • 2N1062 \le N \le 10^6
  • the length of SS is exactly NN characters
  • SS consists of only '0' and '1'
  • 1Q1051 \le Q \le 10^5
  • N×Q2×107N \times Q \le 2 \times 10^7
  • 1K_i1061 \le K\_i \le 10^6