using System;
using System.Linq;

namespace Zadatak_5
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = Convert.ToInt32(input[0]);
            int C = Convert.ToInt32(input[1]);
            int Q = Convert.ToInt32(input[2]);
            string S = Console.ReadLine();
            int[,] LR = new int[Q, 2];
            for (int i = 0; i < Q; i++)
            {
                string[] input_ = Console.ReadLine().Split(' ');
                LR[i, 0] = Convert.ToInt32(input_[0]);
                LR[i, 1] = Convert.ToInt32(input_[1]);
            }
            char[] S_ = S.ToArray();
            int[] output = new int[Q];
            for (int i = 0; i < Q; i++)
            {
                for (int j = LR[i, 0]-1; j <= LR[i, 1]-1; j++)
                {
                    if (S_[j] == '1')
                        S_[j] = '0';
                    else
                        S_[j] = '1';
                }
                string s = string.Join("", S_);
                string string_ = s.Substring(s.IndexOf("1"), s.LastIndexOf("1") - s.IndexOf("1") + 1);
                int zbirJ = 0;
                int zbirN = 0;
                for (int k = 0; k < string_.Length; k++)
                {
                    if (string_[k] == '1')
                        zbirJ += 1;
                    else
                        zbirN += 1;
                }
                if (C + zbirN < zbirJ)
                {
                    output[i] = C + zbirN;
                }
                else
                    output[i] = zbirJ;

            }
            foreach (var item in output)
            {
                Console.WriteLine(item);
            }
        }
    }
}