read N Q
read S

CSUM=(0)
C=0

for i in $(seq 0 $((N-1))); do
    if [ ${S:$i:2} = AC ]; then
        ((C++))
    fi
    CSUM+=($C)
done

# echo ${CSUM[@]}

for i in $(seq $Q); do
    read l r
    R=${CSUM[$((r-1))]}
    L=${CSUM[$((l-1))]}
    
    echo $((R-L))
done