program Nizovi;
type
  niz=array[1..200000] of longint;
var S:string;
  N,C,Q,z,k:longint;
  L,R:niz;
function Minimum(S:string;a:longint):longint;
var i,Nula,Jedan:longint; p:string;
begin
  p:='0'; Nula:=0; Jedan:=0;
  for i:=1 to length(S) do begin
  if p=Copy(S,i,1) then Nula:=Nula+1 else Jedan:=Jedan+1;
  If (Nula+a)<Jedan then Minimum:=Nula+a else Minimum:=Jedan;
  end;
end;
function NoviNiz(S:string;a,b:longint):string;
var i:integer; p:string;
begin
  p:='0'; NoviNiz:=Copy(S,1,a-1);
  for i:=a to b do begin
  if p=Copy(S,i,1) then NoviNiz:=NoviNiz+'1' else NoviNiz:=NoviNiz+'0';
  end;
  NoviNiz:=NoviNiz+Copy(S,b+1,length(S)-b);
end;
begin
readln(N, C, Q); k:=0; if (C>=1) and (N>=C) and (N<=200000) and (Q>=1) and (Q<=200000) then begin readln(S);
if length(S)=N then begin
For z:=1 to Q do begin Readln(L[z],R[z]); if ((L[z]>=1) and (R[z]>=L[z]) and (R[z]<=N)) then k:=0 else k:=1; end;
if k=0 then begin
For z:=1 to Q do begin S:=NoviNiz(S,L[z],R[z]); writeln(Minimum(S,C)); end; end else writeln('Pogresno uneti podaci');
end else writeln('Brojna vrednost duzine nije odgovarajuca');
end else writeln('Pogresno uneti podaci');
readln;
end.