Option Strict On
Module Module1

    Sub Main()
        Dim z() As String = Split(Console.ReadLine())
        Dim N As Integer = Convert.ToInt32(z(0))
        Dim Q As Integer = Convert.ToInt32(z(1))
        Dim S As String = Console.ReadLine()
        Dim l(Q - 1) As Integer
        Dim r(Q - 1) As Integer
        For i As Integer = 0 To Q - 1
            z = Split(Console.ReadLine())
            l(i) = Convert.ToInt32(z(0))
            r(i) = Convert.ToInt32(z(1))
        Next

        '文字列よりACを拾い出し、各文字数目で配列化　ACACTACG　は01122233　
        Dim Ahurag As Integer = 0
        Dim counter As Integer = 0
        Dim at(N - 1) As Integer
        For i As Integer = 0 To N - 1
            If Mid(S, i + 1, 1) = "A" Then
                Ahurag = 1
            ElseIf Ahurag = 1 AndAlso Mid(S, i + 1, 1) = "C" Then
                Ahurag = 0
                counter += 1

            Else
                Ahurag = 0
            End If
            at(i) += counter
        Next

        '出題の最初の文字数目と終わりの文字数目を上記配列に当てはめ差し引きしてACをカウント
        Dim answer As Integer = 0
        For i As Integer = 0 To Q - 1
            answer = at(r(i) - 1) - at(l(i) - 1)
            Console.WriteLine(answer)
        Next
        Console.ReadLine()
    End Sub

End Module