import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private static final int MOD = 1_000_000_007;
    private static final char[] ACGT = new char[]{'A', 'C', 'G', 'T'};

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        // 0 1 2 3 4 5
        // T A C T A C
        // 0 0 1 1 1 2
        int[] sum = new int[n];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        }
    }

    /**
     * AGC, ACG, GAC, A_GC, AG_C
     */
    private boolean ok(char[] a, char b) {
        if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    static class Status {
        int length;
        char[] last3;

        Status(int length, char[] last3) {
            this.length = length;
            this.last3 = last3;
        }

        @Override
        public boolean equals(Object obj) {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        }
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
} import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private static final int MOD = 1_000_000_007;
    private static final char[] ACGT = new char[]{'A', 'C', 'G', 'T'};

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        // 0 1 2 3 4 5
        // T A C T A C
        // 0 0 1 1 1 2
        int[] sum = new int[n];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        }
    }

    /**
     * AGC, ACG, GAC, A_GC, AG_C
     */
    private boolean ok(char[] a, char b) {
        if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    static class Status {
        int length;
        char[] last3;

        Status(int length, char[] last3) {
            this.length = length;
            this.last3 = last3;
        }

        @Override
        public boolean equals(Object obj) {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        }
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
} Main private static final int MOD = 1_000_000_007; MOD 1_000_000_007 private static final char[] ACGT = new char[]{'A', 'C', 'G', 'T'}; ACGT new char[]{'A', 'C', 'G', 'T'} public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    } main {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    } PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) InputStreamScanner in = new InputStreamScanner(System.in); in new InputStreamScanner(System.in) new Main().solve(in, out) new Main().solve new Main() in out out.flush() out.flush out String[] args args private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        // 0 1 2 3 4 5
        // T A C T A C
        // 0 0 1 1 1 2
        int[] sum = new int[n];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        }
    } solve {
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        // 0 1 2 3 4 5
        // T A C T A C
        // 0 0 1 1 1 2
        int[] sum = new int[n];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        }
    } int n = in.nextInt(); n in.nextInt() in.nextInt in int q = in.nextInt(); q in.nextInt() in.nextInt in String s = in.next(); s in.next() in.next in int[] sum = new int[n]; sum new int[n] n for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        } {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        } sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0) sum[i] sum i sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0) sum[i - 1] sum i - 1 i 1 (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0) 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' 1 0 for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        } {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        } int start = in.nextInt(); start in.nextInt() in.nextInt in int end = in.nextInt(); end in.nextInt() in.nextInt in out.println(sum[end - 1] - sum[start - 1]) out.println out sum[end - 1] - sum[start - 1] sum[end - 1] sum end - 1 end 1 sum[start - 1] sum start - 1 start 1 InputStreamScanner in in PrintWriter out out /**
     * AGC, ACG, GAC, A_GC, AG_C
     */
    private boolean ok(char[] a, char b) {
        if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    } ok {
        if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    } if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        } b == 'T' || b == 'A' b == 'T' b 'T' b == 'A' b 'A' {
            return true;
        } return true; true if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        } b == 'G' b 'G' {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            } a[1] == 'A' && a[2] == 'C' a[1] == 'A' a[1] a 1 'A' a[2] == 'C' a[2] a 2 'C' {
                return false;
            } return false; false {
                return true;
            } return true; true if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        } b == 'C' b 'C' {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        } if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            } (a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G') (a[0] == 'A' && a[2] == 'G') (a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G') (a[1] == 'A' && a[2] == 'G') a[1] == 'A' a[1] a 1 'A' a[2] == 'G' a[2] a 2 'G' (a[1] == 'G' && a[2] == 'A') a[1] == 'G' a[1] a 1 'G' a[2] == 'A' a[2] a 2 'A' (a[0] == 'A' && a[2] == 'G') a[0] == 'A' a[0] a 0 'A' a[2] == 'G' a[2] a 2 'G' (a[0] == 'A' && a[1] == 'G') a[0] == 'A' a[0] a 0 'A' a[1] == 'G' a[1] a 1 'G' {
                return false;
            } return false; false {
                return true;
            } return true; true return false; false char[] a a char b b static class Status {
        int length;
        char[] last3;

        Status(int length, char[] last3) {
            this.length = length;
            this.last3 = last3;
        }

        @Override
        public boolean equals(Object obj) {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        }
    } Status int length; length char[] last3; last3 Status(int length, char[] last3) {
            this.length = length;
            this.last3 = last3;
        } Status {
            this.length = length;
            this.last3 = last3;
        } this.length = length this.length this this.length length this.last3 = last3 this.last3 this this.last3 last3 int length length char[] last3 last3 @Override
        public boolean equals(Object obj) {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        } equals {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        } Status s = (Status)obj; s (Status)obj return length == s.length && Arrays.equals(last3, s.last3); length == s.length && Arrays.equals(last3, s.last3) length == s.length length s.length s s.length Arrays.equals(last3, s.last3) Arrays.equals Arrays last3 s.last3 s s.last3 Object obj obj static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    } InputStreamScanner private InputStream in; in private byte[] buf = new byte[1024]; buf new byte[1024] 1024 private int len = 0; len 0 private int off = 0; off 0 InputStreamScanner(InputStream in)	{
            this.in = in;
        } InputStreamScanner {
            this.in = in;
        } this.in = in this.in this this.in in InputStream in in String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        } next {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        } StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            } int b = skip(); int b = skip(); b skip() skip !isSpace(b) isSpace(b) isSpace b {
                sb.appendCodePoint(b);
                b = read();
            } {
                sb.appendCodePoint(b);
                b = read();
            } sb.appendCodePoint(b) sb.appendCodePoint sb b b = read() b read() read return sb.toString(); sb.toString() sb.toString sb int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next char nextChar() {
            return (char)skip();
        } nextChar {
            return (char)skip();
        } return (char)skip(); (char)skip() skip int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        } skip {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        } for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            } int b; int b; b (b = read()) != -1 (b = read()) b read() read -1 1 {
                if (!isSpace(b)) {
                    return b;
                }
            } {
                if (!isSpace(b)) {
                    return b;
                }
            } if (!isSpace(b)) {
                    return b;
                } !isSpace(b) isSpace(b) isSpace b {
                    return b;
                } return b; b return -1; -1 1 private boolean isSpace(int c) {
            return c < 33 || c > 126;
        } isSpace {
            return c < 33 || c > 126;
        } return c < 33 || c > 126; c < 33 || c > 126 c < 33 c 33 c > 126 c 126 int c c private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        } read {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        } if (len == -1) {
                throw new InputMismatchException("End of Input");
            } len == -1 len -1 1 {
                throw new InputMismatchException("End of Input");
            } throw new InputMismatchException("End of Input"); new InputMismatchException("End of Input") if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            } off >= len off len {
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            } off = 0 off 0 try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                } IOException e {
                    throw new InputMismatchException(e.getMessage());
                } throw new InputMismatchException(e.getMessage()); new InputMismatchException(e.getMessage()) {
                    len = in.read(buf);
                } len = in.read(buf) len in.read(buf) in.read in buf if (len <= 0) {
                    return -1;
                } len <= 0 len 0 {
                    return -1;
                } return -1; -1 1 return buf[off++]; buf[off++] buf off++ off public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private static final int MOD = 1_000_000_007;
    private static final char[] ACGT = new char[]{'A', 'C', 'G', 'T'};

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        // 0 1 2 3 4 5
        // T A C T A C
        // 0 0 1 1 1 2
        int[] sum = new int[n];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        }
    }

    /**
     * AGC, ACG, GAC, A_GC, AG_C
     */
    private boolean ok(char[] a, char b) {
        if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    static class Status {
        int length;
        char[] last3;

        Status(int length, char[] last3) {
            this.length = length;
            this.last3 = last3;
        }

        @Override
        public boolean equals(Object obj) {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        }
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
} public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private static final int MOD = 1_000_000_007;
    private static final char[] ACGT = new char[]{'A', 'C', 'G', 'T'};

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        // 0 1 2 3 4 5
        // T A C T A C
        // 0 0 1 1 1 2
        int[] sum = new int[n];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        }
    }

    /**
     * AGC, ACG, GAC, A_GC, AG_C
     */
    private boolean ok(char[] a, char b) {
        if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    static class Status {
        int length;
        char[] last3;

        Status(int length, char[] last3) {
            this.length = length;
            this.last3 = last3;
        }

        @Override
        public boolean equals(Object obj) {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        }
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
} Main
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private static final int MOD = 1_000_000_007;
    private static final char[] ACGT = new char[]{'A', 'C', 'G', 'T'};

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        // 0 1 2 3 4 5
        // T A C T A C
        // 0 0 1 1 1 2
        int[] sum = new int[n];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            out.println(sum[end - 1] - sum[start - 1]);
        }
    }

    /**
     * AGC, ACG, GAC, A_GC, AG_C
     */
    private boolean ok(char[] a, char b) {
        if (b == 'T' || b == 'A') {
            return true;
        } else if (b == 'G') {
            if (a[1] == 'A' && a[2] == 'C') {
                return false;
            } else {
                return true;
            }
        } else if (b == 'C') {
            if ((a[1] == 'A' && a[2] == 'G')
                    || (a[1] == 'G' && a[2] == 'A')
                    || (a[0] == 'A' && a[2] == 'G')
                    || (a[0] == 'A' && a[1] == 'G')
            ) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    static class Status {
        int length;
        char[] last3;

        Status(int length, char[] last3) {
            this.length = length;
            this.last3 = last3;
        }

        @Override
        public boolean equals(Object obj) {
            Status s = (Status)obj;
            return length == s.length && Arrays.equals(last3, s.last3);
        }
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}
