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

namespace _01_niz
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int n = int.Parse(str[0]);
            int c = int.Parse(str[1]);
            int q = int.Parse(str[2]);

            char[] s = Console.ReadLine().ToCharArray();

            for (int k = 0; k < q; k++)
            {
               
                str = Console.ReadLine().Split();
                int l = int.Parse(str[0]);
                int r = int.Parse(str[1]);

                Okreni(s, l, r);

                bool jedinicaPre = false;
                int br = 0;
                int brojNulaUNizu = 0;

                for (int i = 0; i < n; i++)
                {
                    if (s[i]=='0' && jedinicaPre)
                    {
                        br++;
                        brojNulaUNizu++;
                    }
                    if (s[i]=='1')
                    {
                        jedinicaPre = true;
                        brojNulaUNizu = 0;
                    }
                }

                br -= brojNulaUNizu;
                br += c;

                int jedinice = Prebroj(s, '1');
                

                br = Math.Min(br, jedinice);
                Console.WriteLine(br); 

            }
            Console.ReadLine(); 


        }
        static void Okreni(char[] s,int l, int r)
        {
            for (int i = l - 1; i < r; i++)
            {
                Zameni(s, i);
            }
        }

        static int Prebroj(char[] s, char c)
        {
            int br = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i]==c)
                {
                    br++;
                }
            }
            return br;
        }

        static void Zameni(char[] s,int i)
        {
            if (s[i] == '1')
            {
                s[i] = '0';
            }
            else
            {
                s[i] = '1';
            }
        }
    }
}