#include <iostream>
#include <string>

using namespace std;

int niz1[1000000];
int niz2[1000000];



int main()
{
    int n,c,q;
    cin>>n>>c>>q;
    string s;
    cin>>s;
    for(int i=0;i<q;i++)
    {
        cin>>niz1[i]>>niz2[i];
    }
    int suman;
    int k;
    int sumaj;
    for(int i=0;i<q;i++)
    {
        k=niz1[i];
        suman=0;
        sumaj=0;
        while(k<=niz2[i])
        {
            if(s[k-1]=='1')
            {
                s[k-1]='0';
            }
            else s[k-1]='1';
            k++;

        }
        //cout<<s<<endl;
        for(int j=0;j<n;j++)
        {
            if(s[j]=='1')sumaj+=1;
            else suman+=1;
        }
        //cout<<sumaj<<" "<<suman;
        if(suman+c<=sumaj)cout<<suman+c<<endl;
        else
            cout<<sumaj<<endl;
    }



}