#include<iostream>
using namespace std;
main(){
int N,C,Q;
cin>>N>>C>>Q;
int L[Q];
int R[Q];
int br=0;
int brjp = 0;
int k=0;
int brn[10000];
int brj[10000];
int h=0;
string s;
cin>>s;
string s1 = s;
for (int i = 0; i < Q; i++)
{
    cin>>L[i];
    cin>>R[i];
}
for(int i = 0; i < Q; i++)
{
    for (int j = L[i]-1; j <= R[i]-1; j++)
    {
        if (s[j] == 48) s[j] = 49;
        else s[j] = 48;
    }
    if(C==N){
        for (int j = 0; j < s.size(); j++)
        {
            if (s[j] == 49) br++;
        }
    }
    else if(C==1){
        for(int j=0;j<s.size();j++)
        {
            if(s[j]==49){
                br++;
                while(s[j]==49)j++;
            }
        }
    }
    cout<<br<<endl;
    br=0;
    }


}