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

namespace takimcenje5._2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, c, q,a=0,b=0,b0=0,b1=0,pj=0,cena=0,e=0,poj=0;
            string[] nz = Console.ReadLine().Split();
            n = int.Parse(nz[0]);
            c = int.Parse(nz[1]);
            q = int.Parse(nz[2]);
            string s = Console.ReadLine();
            int[] l = new int[q];
            int[] r = new int[q];
            int[] nizc = new int[n];
            for(int i=0;i<q;i++)
            {
                string[] nz1 = Console.ReadLine().Split();
                l[i]= int.Parse(nz1[0]);
                r[i] = int.Parse(nz1[1]);
            }
            for(int i=0;i<n;i++)
            {
                nizc[i] = Convert.ToInt32(s[i]);
                if (nizc[i] == 1)
                    b1++;
                else
                    b0++;
                e = b0;
                a = b1;
            }
            for(int i=0;i<q;i++)
            {
                for(int j=l[i];j<=r[i];j++)
                {
                    if (nizc[j] == 1)
                        nizc[j]=0;
                    else
                        nizc[j] = 1;
                }
                b1 = 0;
                b0 = 0;
                for (int j = 0; j < n; j++)
                {
                    if (nizc[j] == 1)
                    {
                        b1++;
                    }
                    else
                    {
                        b0++;
                    }
                    e = b0;
                    a = b1;
                }
                if (c >= a || c==n)
                {
                    cena = e;
                }
                else
                {
                    b1 = 0;b0 = 0;
                    while(nizc[pj]==0)
                        pj++;
                    poj = n - 1;
                    while (nizc[poj] == 0)
                        poj--;
                    for (int j = pj; j <= poj; j++)
                    {
                        if (nizc[j] == 1)
                        {
                            b0++;
                        }
                        else
                        {
                            b1++;
                        }
                    }
                    if (c + b0 >= b1)
                        cena = e;
                    else
                        cena = c + a;
                }
                Console.WriteLine(cena);
            }
            Console.ReadLine();
        }
    }
}