import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), Q = s.nextInt();
		int[] a = new int [N];
		a[0] = 0;
		String S = s.next();
		for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		}
		for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		}
	}
	public static int plus(int a, String s){
		int Flag = 0;
		if (s.equals("AC")){
			Flag = 1;
		}
		return a + Flag;
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), Q = s.nextInt();
		int[] a = new int [N];
		a[0] = 0;
		String S = s.next();
		for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		}
		for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		}
	}
	public static int plus(int a, String s){
		int Flag = 0;
		if (s.equals("AC")){
			Flag = 1;
		}
		return a + Flag;
	}
} Main public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), Q = s.nextInt();
		int[] a = new int [N];
		a[0] = 0;
		String S = s.next();
		for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		}
		for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		}
	} main {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), Q = s.nextInt();
		int[] a = new int [N];
		a[0] = 0;
		String S = s.next();
		for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		}
		for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int N = s.nextInt() N s.nextInt() s.nextInt s Q = s.nextInt(); Q s.nextInt() s.nextInt s int[] a = new int [N]; a new int [N] N a[0] = 0 a[0] a 0 0 String S = s.next(); S s.next() s.next s for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		} {
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		} String SS = S.substring(i - 1, i + 1); SS S.substring(i - 1, i + 1) S.substring S i - 1 i 1 i + 1 i 1 a[i] = plus(a[i - 1], SS) a[i] a i plus(a[i - 1], SS) plus a[i - 1] a i - 1 i 1 SS for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		} int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		} {
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		} System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]) System.out.println System.out System System.out - a[s.nextInt() - 1] + a[s.nextInt() - 1] - a[s.nextInt() - 1] a[s.nextInt() - 1] a s.nextInt() - 1 s.nextInt() s.nextInt s 1 a[s.nextInt() - 1] a s.nextInt() - 1 s.nextInt() s.nextInt s 1 String[] args args public static int plus(int a, String s){
		int Flag = 0;
		if (s.equals("AC")){
			Flag = 1;
		}
		return a + Flag;
	} plus {
		int Flag = 0;
		if (s.equals("AC")){
			Flag = 1;
		}
		return a + Flag;
	} int Flag = 0; Flag 0 if (s.equals("AC")){
			Flag = 1;
		} s.equals("AC") s.equals s "AC" {
			Flag = 1;
		} Flag = 1 Flag 1 return a + Flag; a + Flag a Flag int a a String s s public class Main {
	public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), Q = s.nextInt();
		int[] a = new int [N];
		a[0] = 0;
		String S = s.next();
		for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		}
		for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		}
	}
	public static int plus(int a, String s){
		int Flag = 0;
		if (s.equals("AC")){
			Flag = 1;
		}
		return a + Flag;
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), Q = s.nextInt();
		int[] a = new int [N];
		a[0] = 0;
		String S = s.next();
		for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		}
		for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		}
	}
	public static int plus(int a, String s){
		int Flag = 0;
		if (s.equals("AC")){
			Flag = 1;
		}
		return a + Flag;
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), Q = s.nextInt();
		int[] a = new int [N];
		a[0] = 0;
		String S = s.next();
		for (int i = 1; i < N; i++){
			String SS = S.substring(i - 1, i + 1);
			//System.out.println(SS);
			a[i] = plus(a[i - 1], SS);
			//System.out.println(a[i]);
		}
		for (int i = 0; i < Q; i++){
			System.out.println(- a[s.nextInt() - 1] + a[s.nextInt() - 1]);
		}
	}
	public static int plus(int a, String s){
		int Flag = 0;
		if (s.equals("AC")){
			Flag = 1;
		}
		return a + Flag;
	}
}
