import java.util.Scanner;

import javax.xml.validation.SchemaFactoryConfigurationError;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];

		for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		//lcnt[i]・・・1文字目から i 文字目までのACの数
		int[] lcnt = new int[n + 1];
		lcnt[0] = 0;
		lcnt[1] = 0;

		for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		}

		for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		}

		sc.close();
	}
} import java.util.Scanner; Scanner java.util import javax.xml.validation.SchemaFactoryConfigurationError; SchemaFactoryConfigurationError javax.xml.validation public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];

		for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		//lcnt[i]・・・1文字目から i 文字目までのACの数
		int[] lcnt = new int[n + 1];
		lcnt[0] = 0;
		lcnt[1] = 0;

		for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		}

		for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		}

		sc.close();
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];

		for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		//lcnt[i]・・・1文字目から i 文字目までのACの数
		int[] lcnt = new int[n + 1];
		lcnt[0] = 0;
		lcnt[1] = 0;

		for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		}

		for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		}

		sc.close();
	} main {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];

		for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		//lcnt[i]・・・1文字目から i 文字目までのACの数
		int[] lcnt = new int[n + 1];
		lcnt[0] = 0;
		lcnt[1] = 0;

		for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		}

		for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		}

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc String s = sc.next(); s sc.next() sc.next sc int[] l = new int[q]; l new int[q] q int[] r = new int[q]; r new int[q] q for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		} {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		} l[i] = sc.nextInt() l[i] l i sc.nextInt() sc.nextInt sc r[i] = sc.nextInt() r[i] r i sc.nextInt() sc.nextInt sc int[] lcnt = new int[n + 1]; lcnt new int[n + 1] n + 1 n 1 lcnt[0] = 0 lcnt[0] lcnt 0 0 lcnt[1] = 0 lcnt[1] lcnt 1 0 for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		} {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		} lcnt[i + 2] = lcnt[i + 1] lcnt[i + 2] lcnt i + 2 i 2 lcnt[i + 1] lcnt i + 1 i 1 if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			} s.substring(i, i + 2).equals("AC") s.substring(i, i + 2).equals s.substring(i, i + 2) s.substring s i i + 2 i 2 "AC" {
				lcnt[i + 2]++;
			} lcnt[i + 2]++ lcnt[i + 2] lcnt i + 2 i 2 for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		} {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		} System.out.println(lcnt[r[i]] - lcnt[l[i]]) System.out.println System.out System System.out lcnt[r[i]] - lcnt[l[i]] lcnt[r[i]] lcnt r[i] r i lcnt[l[i]] lcnt l[i] l i sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];

		for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		//lcnt[i]・・・1文字目から i 文字目までのACの数
		int[] lcnt = new int[n + 1];
		lcnt[0] = 0;
		lcnt[1] = 0;

		for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		}

		for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		}

		sc.close();
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];

		for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		//lcnt[i]・・・1文字目から i 文字目までのACの数
		int[] lcnt = new int[n + 1];
		lcnt[0] = 0;
		lcnt[1] = 0;

		for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		}

		for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		}

		sc.close();
	}
} Main
import java.util.Scanner;

import javax.xml.validation.SchemaFactoryConfigurationError;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];

		for (int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		//lcnt[i]・・・1文字目から i 文字目までのACの数
		int[] lcnt = new int[n + 1];
		lcnt[0] = 0;
		lcnt[1] = 0;

		for (int i = 0; i < n - 1; i++) {
			lcnt[i + 2] = lcnt[i + 1];
			if (s.substring(i, i + 2).equals("AC")) {
				lcnt[i + 2]++;
			}
		}

		for (int i = 0; i < q; i++) {
//			System.out.print("i:" + i + ", ");
//			System.out.print(
//					"lcnt[" + r[i] + "]:" + lcnt[r[i]] + ", lcnt[" + (l[i]) + "]:" + lcnt[l[i]] + ", ans:");
			System.out.println(lcnt[r[i]] - lcnt[l[i]]);
		}

		sc.close();
	}
}