import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main 
{	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), Q = Integer.parseInt(ST.nextToken());
		String S = BR.readLine();
		int PSA[] = new int[S.length() + 1];
		for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		}
		for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1];
		for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main 
{	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), Q = Integer.parseInt(ST.nextToken());
		String S = BR.readLine();
		int PSA[] = new int[S.length() + 1];
		for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		}
		for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1];
		for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		}
	}
} Main public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), Q = Integer.parseInt(ST.nextToken());
		String S = BR.readLine();
		int PSA[] = new int[S.length() + 1];
		for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		}
		for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1];
		for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		}
	} main {
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), Q = Integer.parseInt(ST.nextToken());
		String S = BR.readLine();
		int PSA[] = new int[S.length() + 1];
		for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		}
		for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1];
		for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		}
	} BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); BR new BufferedReader(new InputStreamReader(System.in)) StringTokenizer ST = new StringTokenizer(BR.readLine()); ST new StringTokenizer(BR.readLine()) int N = Integer.parseInt(ST.nextToken()) N Integer.parseInt(ST.nextToken()) Integer.parseInt Integer ST.nextToken() ST.nextToken ST Q = Integer.parseInt(ST.nextToken()); Q Integer.parseInt(ST.nextToken()) Integer.parseInt Integer ST.nextToken() ST.nextToken ST String S = BR.readLine(); S BR.readLine() BR.readLine BR int PSA[] = new int[S.length() + 1]; PSA new int[S.length() + 1] S.length() + 1 S.length() S.length S 1 for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		} int i = 1; int i = 1; i 1 i < S.length() i S.length() S.length S i++ i++ i {
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		} {
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		} if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++; S.charAt(i - 1) == 'A' && S.charAt(i) == 'C' S.charAt(i - 1) == 'A' S.charAt(i - 1) S.charAt S i - 1 i 1 'A' S.charAt(i) == 'C' S.charAt(i) S.charAt S i 'C' PSA[i]++ PSA[i] PSA i for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1]; int i = 1; int i = 1; i 1 i <= S.length() i S.length() S.length S i++ i++ i PSA[i] += PSA[i - 1]; PSA[i] += PSA[i - 1] PSA[i] PSA i PSA[i - 1] PSA i - 1 i 1 for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		} int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		} {
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		} ST = new StringTokenizer(BR.readLine()) ST new StringTokenizer(BR.readLine()) int l = Integer.parseInt(ST.nextToken()) l Integer.parseInt(ST.nextToken()) Integer.parseInt Integer ST.nextToken() ST.nextToken ST r = Integer.parseInt(ST.nextToken()); r Integer.parseInt(ST.nextToken()) Integer.parseInt Integer ST.nextToken() ST.nextToken ST int count = PSA[r - 1] - PSA[l - 1]; count PSA[r - 1] - PSA[l - 1] PSA[r - 1] PSA r - 1 r 1 PSA[l - 1] PSA l - 1 l 1 System.out.println(count) System.out.println System.out System System.out count String[] Arguments Arguments public class Main 
{	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), Q = Integer.parseInt(ST.nextToken());
		String S = BR.readLine();
		int PSA[] = new int[S.length() + 1];
		for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		}
		for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1];
		for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		}
	}
} public class Main 
{	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), Q = Integer.parseInt(ST.nextToken());
		String S = BR.readLine();
		int PSA[] = new int[S.length() + 1];
		for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		}
		for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1];
		for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main 
{	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), Q = Integer.parseInt(ST.nextToken());
		String S = BR.readLine();
		int PSA[] = new int[S.length() + 1];
		for (int i = 1; i < S.length(); i++)
		{
			if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') PSA[i]++;
		}
		for (int i = 1; i <= S.length(); i++) PSA[i] += PSA[i - 1];
		for (int i = 0; i < Q; i++)
		{
			ST = new StringTokenizer(BR.readLine());
			int l = Integer.parseInt(ST.nextToken()), r = Integer.parseInt(ST.nextToken());
			int count = PSA[r - 1] - PSA[l - 1];
			System.out.println(count);
		}
	}
}
