#include <iostream>
#include <string>
#include <cctype>
#include <stdio.h>
#include <math.h>

using namespace std;

int brojJedinica(string datiString){
    int broj=0;
    for(int i=0; i<datiString.length(); i++){
        if(datiString[i]=='1')broj++;
    }
    return broj;
}

string trim(string datiString){
    string ret=datiString;
    while(ret[0]!='1'){
        ret.erase(ret.begin());
    }

    while(ret[ret.length()-1]!='1'){
        ret.erase(ret.end()-1);
    }
    return ret;
}

string invert(string datiString){
    string retval="";
    for(int i=0; i<datiString.length(); i++){
        if(datiString[i]=='0')retval+='1';
        else retval+='0';
    }
    return retval;
}

int main()
{
    int duzinaStringa;
    int cenaOkretaPodstringa;
    int brojPromena;

    cin>>duzinaStringa;
    cin>>cenaOkretaPodstringa;
    cin>>brojPromena;

    string datiString;
    cin>>datiString;

    for(int i=0; i<brojPromena; i++){
        int l1;
        int r1;
        cin>>l1>>r1;
        l1=l1-1;
        datiString=datiString.substr(0,l1)+invert(datiString.substr(l1,r1))+datiString.substr(r1,duzinaStringa);
        string stringProvere=trim(datiString);
        //cout<<brojJedinica(stringProvere)<<" "<<stringProvere.length()-brojJedinica(stringProvere)+cenaOkretaPodstringa<<endl;
        int cena1 = brojJedinica(stringProvere);
        int cena2 = stringProvere.length()-brojJedinica(stringProvere)+cenaOkretaPodstringa;
        cout<<min(cena1,cena2)<<endl;
        //cout<<stringProvere;
    }
}