Lovely Fish
题号:NC237098
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Fish is a working-class citizen, he works for company H(Heinz). One day, Fish wants to know how much his coworkers like him.
After some research, Fish organized the results into a string S
  1. when , this means that the i-th worker likes Fish.
  2. when , this means that the i-th worker dislikes Fish.
After researching,Fish copied down as a new string T,and saw that there were many 0s among T, he became very sad. So he wished to insert some 1 to any position of T in order to make himself happier.
If the length of T is m after inserts,Fish would become sad under either of the following two conditions:
  1. there exists a which the number of 0 are strictly larger than the number of 1 within T_1 to T_p.
  2. there exists a which the number of 0 are strictly larger than the number of 1 within T_p to T_m.
Fish also doesn't know for certain the value of l and r, so he wants to know with q possible pairs of l and r, the least number of inserts that Fish needs to make in order to make himself happy.

输入描述:

The first line contains two integers  denoting the numbers of colleagues and questions.
The second line contains a string S.
For the next q lines, each line contains two integers l_i, r_i, requesting the least number of changes if T=.

输出描述:

To reduce the impact of output time, you only need to output the  of each query.
示例1

输入

复制
10 5
0001001111
1 6
1 10
5 7
4 7
4 6

输出

复制
0

说明

For the example, the answers are 5,4,2,1,2.
the possible solutions are:
000100->10101010101
0001001111->11100010101111
001->10101
1001->10101
100->10101