namespace _3_
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            char[] a = Console.ReadLine().ToArray();
            int[] rez = new int[n[1]];
            for (int i = 0; i < n[1]; i++)
            {
                int[] red = Console.ReadLine().Split().Select(int.Parse).ToArray();

                char[] b = new char[a.Length];
                for(int j = 0; j < a.Length; j++)
                    b[j] = a[j];

                if (b[0] == '?')
                    b[0] = '6';
                if (b[red[1] - 1] == '?')
                    b[red[1]-1] = '7';
                for (int j = 1; j < red[1]; j++)
                {
                    if (b[j] == '?')
                    {
                        if (b[j - 1] != '6') 
                            b[j] = '6';
                        else 
                            b[j] = '7';
                    }
                }
                int k = 0;
                for (int j = red[0]-1; j < red[1]-1; j++)
                {
                    if (b[j] == '6')
                    {
                        if (b[j + 1] == '7')
                        {
                            k++;
                        }
                    }
                }
                rez[i] = k * 2 + (k * (k - 1)) / 2;
                if (b[red[1] - 1] == '6' && b[red[1] - 2] == '7')
                    rez[i]--;
            }
                Console.WriteLine();
                foreach(int s in rez)
                    Console.WriteLine(s);
        }
    }
}