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

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

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

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

                }
                string nbt;
             int pomSuma = 0;
             for (int i = 0; i < ekonomicno.Length; i++)
                  pomSuma += int.Parse(ekonomicno[i].ToString());
                if (pomSuma > c)
                {
                    nbt = Zamena(ekonomicno);
                    unos = unos.Replace(ekonomicno, nbt);
                    ukupnaCena += c;
                }
                else
                {
                    ukupnaCena += pomSuma;
                    break;
                }
            }
            return ukupnaCena;
            }
        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[] niz = 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 (niz[j] == '1')
                        niz[j] = '0';
                    else
                        niz[j] = '1';
                }
                string pom = new string(niz);
                Console.WriteLine(cena(pom, c));

            }
            Console.ReadLine();
        }
    }
}