human
Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.

Let's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).

You are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).

You have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.

The second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.

The following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.

Output

For each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.

Example

Input

5 4
baacb
1 3
1 5
4 5
2 3

Output

1
2
0
1

Note

Consider the queries of the example test.

  * in the first query, the substring is baa, which can be changed to bac in one operation.

  * in the second query, the substring is baacb, which can be changed to cbacb in two operations.

  * in the third query, the substring is cb, which can be left unchanged.

  * in the fourth query, the substring is aa, which can be changed to ba in one operation. 
 ... What is a Python program to print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive?
assistant
#Here is Python program to print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.

def main():
    mod=1000000007
    # mod=998244353
    # nCr =  make_nCr_mod()
    
    tc=1
    for _ in range(tc):
        n,m=ria()
        s=rs()
        poss=["abc"*n,"acb"*n,"bca"*n,"bac"*n,"cab"*n,"cba"*n]
        z=[]
        
        def zapper(t):
            pref=[0]
            ps=0
            for i in range(n):
                if s[i]!=t[i]:
                    ps+=1
                pref.append(ps)
            return pref
        for t in poss:
            z.append(zapper(t))
        
        for i in range(m):
            l,r=ria()
            ans=INF
            for j in z:
                ans=min(ans,j[r]-j[l-1])
            wi(ans)
            
            
            
        
        
        
        
            
            
            
            
                      
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
            
def rant():
    # RANT BEGINS-
    # 
    # Did you look at the constraints dummy? Read problem again carefully understand it correctly
    # Are base cases correct n=0,n=1,n=N or string is all 0 or all 1?
    # Take hints from time limits maybe n=1000 and m=100000 so if n^2 doesnt work n*m might work?? 
    # Upto 10^8 works under 2 sec
    # 
    # 1.Greedy? What matters what doesnt? Is my claim correct? 
    #   Does my implementation correctly implements the greedy i thought of? 
    #   Dictionary? keep a count of values if constraint on something is low(like only alphabets(26) count)? 
    # 
    # 2.DP? Think about state's ranges maybe one of the states have lesser possible values than it may look like? 
    #   Obviously think about order of evaluation
    # 
    # 3.Binary Search?(Monotonic? any one directed order in which we have to perform something?)
    # 
    # 4.Graph?DSU?Edge property or Vertex property Read carefully? Bipartitenes...