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

awk -v CSUM="${CSUM[*]}" '
BEGIN { split(CSUM, ARR, " ")}
{print  ARR[$2]-ARR[$1]}
'