#include <bits/stdc++.h>

using namespace std;

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

    int N,C,Q;
    cin >> N >> C >> Q;
    string s;
    cin >> s;
    for(int q = 0;q<Q;q++)
    {
        int L,R;
        cin >> L >> R;
        for(int i = L;i<=R;i++)
        {
            if(s[i-1] == '1')
                s[i-1] = '0';
            else
                s[i-1] = '1';
        }
        int res = 0;
        if(C == 1)
        {

            for(int i = 0;i<N-1;i++)
            {
                if(s[i] == '1' && s[i+1] == '0')
                    res++;
            }
            if(s[N-1] == '1')
                res++;
        }
        else if(C == N)
        {
            for(int i = 0;i<N;i++)
                if(s[i] == '1')
                res++;
        }
        else
        {
            int first1Pos = N-1;
            int Ncnt = 0;
            int las1Pos = 0;
            for(int i = 0;i<N;i++)
            {
                if(s[i] == '1' && first1Pos == N-1)
                    first1Pos = i;
                if(s[i] == '1')
                    las1Pos = i;
            }
            for(int i = first1Pos+1;i<las1Pos;i++)
            {
                if(s[i] == '0')
                    Ncnt++;
            }
            //cout << Ncnt << "\t" << (las1Pos+1-first1Pos-Ncnt) << endl;
            if((las1Pos+1-first1Pos-Ncnt) - Ncnt > C)
            {
                res += C;
                res += Ncnt;
            }
            else
            {
                res += las1Pos+1-first1Pos-Ncnt;
            }
        }
        cout << res << endl;
    }

    return 0;
}