import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int Q = sc.nextInt();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 }
} import java.util.*; util.* java public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int Q = sc.nextInt();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int Q = sc.nextInt();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 } main {
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int Q = sc.nextInt();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 } 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 char[] S = sc.next().toCharArray(); S sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int l; l int r; r int ans=0; ans 0 int[] forans = new int[N]; forans new int[N] N for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     } int i=1; int i=1; i 1 i<N i N i++ i++ i {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     } {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     } if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       } S[i-1]=='A'&&S[i]=='C' S[i-1]=='A' S[i-1] S i-1 i 1 'A' S[i]=='C' S[i] S i 'C' {
         ans++;
       } ans++ ans forans[i]=ans forans[i] forans i ans for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   } int i=0; int i=0; i 0 i<Q i Q i++ i++ i {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   } {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   } l=sc.nextInt() l sc.nextInt() sc.nextInt sc r=sc.nextInt() r sc.nextInt() sc.nextInt sc ans = forans[r-1] - forans[l-1] ans forans[r-1] - forans[l-1] forans[r-1] forans r-1 r 1 forans[l-1] forans l-1 l 1 System.out.println(ans) System.out.println System.out System System.out ans 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();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 }
} public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int Q = sc.nextInt();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 }
} Main
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int Q = sc.nextInt();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 }
}