#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define MAXN 200010

using namespace std;

pii seg[4*MAXN];
bool lazy[4*MAXN];
int n, c, q, a[MAXN];
string s;

pii sumiraj(pii x, pii y)
{
    pii ress={x.xx+y.xx, x.yy+y.yy};
    return ress;
}

void relax(int node, int l, int r)
{
    if (lazy[node]==0) return;
    seg[node]={seg[node].yy, seg[node].xx};
    if (l!=r)
    {
        lazy[2*node]^=lazy[node];
        lazy[2*node+1]^=lazy[node];
    }
    lazy[node]=0;
}

void build(int node, int l, int r)
{
    if (l==r) { if (s[l-1]=='0') seg[node].xx=1; else seg[node].yy=1; return; }
    int mid=l+(r-l)/2;
    build(2*node, l, mid); build (2*node+1, mid+1, r);
    seg[node]=sumiraj(seg[2*node], seg[2*node+1]);
}

void update(int node, int l, int r, int levo, int desno) ///[l,r]-gde sam u segmentnom; [levo, desno]-query;
{
    relax(node, l, r);
    if (levo>r || desno<l) return;
    if (levo<=l && desno>=r) { lazy[node]^=1; return; }

    int mid=l+(r-l)/2;
    update(2*node, l, mid, levo, desno);
    update(2*node+1, mid+1, r, levo, desno);
    relax(2*node, l, mid);
    relax(2*node+1, mid+1, r);

    seg[node]=sumiraj(seg[2*node], seg[2*node+1]);
}

int query(int node, int l, int r, int levo, int desno)
{
    relax(node, l, r);
    if (levo>r || desno<l) return 0;
    if (levo<=l && desno>=r) return seg[node].yy;

    int mid=l+(r-l)/2;
    return (query(2*node, l, mid, levo, desno)+query(2*node+1, mid+1, r, levo, desno));
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>>n>>c>>q>>s;

    if (c==n)
    {
        build(1, 1, n);
        while (q--)
        {
            int l, r; cin>>l>>r;
            int kec=0, nula=0;
            update(1, 1, n, l, r);
            cout<<query(1, 1, n, 1, n)<<endl;
        }
    }
    else if (q==1)
    {
        int l, r; cin>>l>>r;
        for (int i=0; i<s.size(); i++) a[i]=s[i]-'0';
        l--; r--;
        for (int i=l; i<=r; i++) a[i]^=1;
        int kolko=0, ress=0;
        for (int i=0; i<n; i++)
        {
            if (a[i]==1)
            {
                int ii=i;
                while (i<n && a[i]==1) i++;
                int kolko=i-ii;
                ress+=min(kolko, c);
                i--;
            }
        }
        cout<<ress;
    }
    else if (c==1 && n<=4000 && q<=4000)
    {
        for (int i=0; i<s.size(); i++) a[i]=s[i]-'0';
        while (q--)
        {
            int l, r; cin>>l>>r;
            l--; r--;
            for (int i=l; i<=r; i++) a[i]^=1;
            int kolko=0, ress=0;
            for (int i=0; i<n; i++)
            {
                if (a[i]==1)
                {
                    int ii=i;
                    while (i<n && a[i]==1) i++;
                    ress++;
                    i--;
                }
            }
            cout<<ress<<endl;
        }
    }

}