using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program
{
    class Program
    {
        static string Zamena(string x)
        {
            string brojevi = "";
            foreach (char znak in x)
                if (znak == '0')
                    brojevi += 1;
                else
                    brojevi += 0;
            return brojevi;
        }
        static int cena(string unos, int c)
        {
            double max = 0;
            string pop = "";
            var karakteri = unos.ToCharArray();
            int[] array = new int[karakteri.Length];
            for (int i = 0; i < karakteri.Length; i++)
                array[i] = int.Parse(karakteri[i].ToString());
            int uc = 0;
            while (true)
            {
                max = 0;
                pop = unos;
                for (int i = 0; i < karakteri.Length; i++)
                    array[i] = int.Parse(unos.ToCharArray()[i].ToString());
                for (int x = 0; x < karakteri.Length - c + 1; x++)
                {

                    for (int j = karakteri.Length; j > c - 1 + x; j--)
                    {
                        int pom = 0;
                        string pomeraj = "";
                        for (int i = x; i < j; i++)
                        {
                            pom += array[i];
                            pomeraj += array[i].ToString();
                        }
                        if ((((double)pom / (j - x)) * pom) > max && (j - x) > c)
                        {

                            pop = "";
                            max = (((double)pom / (j - x)) * pom);
                            for (int i = x; i < j; i++)
                                pop += array[i].ToString();
                        }
                        if ((((double)pom / (j - x)) * pom) == max && (j - x) > c)
                        {
                            if (pom / (j - x) > pop.Length)
                            {
                                pop = "";
                                max = (((double)pom / (j - x)) * pom);
                                for (int i = x; i < j; i++)
                                    pop += array[i].ToString();
                            }
                        }
                    }

                }
                int s = 0;
                string pp;
                foreach (char x in pop)
                    s += int.Parse(x.ToString());
                if (s > c)
                {
                    pp = Zamena(pop);
                    unos = unos.Replace(pop, pp);
                    uc += c;
                }
                else
                {
                    s = array.Sum();
                    uc += s;
                    break;
                }
            }
            return uc;
        }
        static void Main(string[] args)
        {
            var ulaz = Console.ReadLine().Split();
            int n = int.Parse(ulaz[0]);
            int c = int.Parse(ulaz[1]);
            int q = int.Parse(ulaz[2]);
            int[] L = new int[q];
            int[] R = new int[q];
            char[] array = Console.ReadLine().ToCharArray();
            for (int i = 0; i < q; i++)
            {
                ulaz = Console.ReadLine().Split();
                L[i] = int.Parse(ulaz[0]) - 1;
                R[i] = int.Parse(ulaz[1]) - 1;
            }

            for (int i = 0; i < q; i++)
            {
                for (int j = L[i]; j <= R[i]; j++)
                {
                    if (array[j] == '1')
                        array[j] = '0';
                    else
                        array[j] = '1';
                }
                string pom = new string(array);
                Console.WriteLine(cena(pom, c));

            }
            Console.ReadKey();
        }
    }
}