#include <iostream>
#include <string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

string promena(string s, int Li, int Ri){
	for(int i=Li-1;i<Ri;i++){
		if(s[i]=='0'){
			s[i]='1';
		}else if(s[i]=='1'){
			s[i]='0';
		}
	}
	return s;
}

int cena(string s, int n, int c){
	
	long long max=1000000000000;
	string s1,s2;
	s1=s;
	s2=s;
	int lo=0,ro=n-1;
	while(s[lo]=='0'){
		lo++;
	}
	while(s[ro]=='0'){
		ro--;
	}
	
	int p=lo;
	long long br1=0;	
	while(p<=ro){
		int br=0;
		while(s1[p]=='1'){
			br++;
			p++;
		}
		if(br<c){
			br1+=br;
		}else {
			br1+=c;
		}
		br=0;
		while(s1[p]=='0'){
			p++;
		}
	}
	if(br1<max){
		max=br1;
	} 
	
	s2=promena(s2,lo,ro+1);
	int t=lo;
	long long br2=0;
	br2+=c;	
	while(t<=ro){
		int br=0;
		while(s2[t]=='1'){
			br++;
			t++;
		}
		if(br<c){
			br2+=br;
		}else {
			br2+=c;
		}
		br=0;
		while(s2[t]=='0'){
			t++;
		}
	}
	if(br2<max){
		max=br2;
	}
	
	return max;
}

int main(int argc, char** argv) {
	
	int n,c,q;
	int Li,Ri;
	cin>>n>>c>>q;
	string s;
	cin>>s;
	int a[q];
	int b[q];
	for(int i=0;i<q;i++){
		cin>>Li>>Ri;
		s=promena(s,Li,Ri);
		b[i]=cena(s,n,c);
	}
	for(int i=0;i<q;i++){
		cout<<b[i]<<endl;
	}
	
	return 0;
}