// Arup Guha
// 2/12/2021
// Solution to 2021 USACO January Silver Problem: No Time to Paint
 
import java.util.*;
import java.io.*;

public class nopaint {

	public static void main(String[] args) throws Exception {
	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		
		int n = Integer.parseInt(tok.nextToken());
		int q = Integer.parseInt(tok.nextToken());

		// Get what to paint.
		char[] paint = stdin.readLine().toCharArray();
		
		// Will store min # colors painting from left here.
		int[] forward = new int[n];
		
		// The stack maintains what colors could be underneath, in the order they could be underneath.
		Stack<Character> s = new Stack<Character>();
		forward[0] = 1;
		s.push(paint[0]);
		
		// Go through each color.
		for (int i=1; i<n; i++) {
		
			// This just means we have to stop the topmost paints that are a darker color than the next color.
			while (s.size() > 0 && s.peek() > paint[i]) s.pop();
			
			// A new color must be added, so push this to the top.
			if (s.size() == 0 || paint[i] > s.peek()) {
				forward[i] = forward[i-1]+1;
				s.push(paint[i]);
			}
			
			// We uncover a previous strip that is still continuing.
			else 
				forward[i] = forward[i-1];
		}
		
		// Repeat the process from the right side.
		s = new Stack<Character>();
		s.push(paint[n-1]);
		int[] back = new int[n];
		back[n-1] = 1;
		
		// Paint right to left.
		for (int i=n-2; i>=0; i--) {
			
			// Forced to stop these darker strips.
			while (s.size() > 0 && s.peek() > paint[i]) s.pop();
			
			// Must start a new color; add it to the stack.
			if (s.size() == 0 || paint[i] > s.peek()) {
				back[i] = back[i+1]+1;
				s.push(paint[i]);
			}
			
			// Lucky, we uncovered the color we needed from an old strip still continuing.
			else 
				back[i] = back[i+1];		
		}
		
		// We answer each query as two cumulative sums.
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<q; i++) {
			
			// Get the query.
			tok = new StringTokenizer(stdin.readLine());
			int low = Integer.parseInt(tok.nextToken()) - 2;
			int high = Integer.parseInt(tok.nextToken());
			
			// Add in the appropriate items, if necessary.
			int res = 0;
			if (low >= 0) res += forward[low];
			if (high < n) res += back[high];
			sb.append(res+"\n");
		}
		System.out.print(sb);
	}
}