#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
        {

        }
        cout << res << endl;
    }

    return 0;
}