#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, c, q;
    cin >> n >> c >> q;
    string s;
    cin >> s;
    char arr[n + 1];
    strcpy(arr, s.c_str());
    int o_c;
    for(int i = 0; i < q; i++)
    {
        o_c = 0;
        int l, r;
        cin >> l >> r;
        for(int j = l - 1; j < r; j++)
        {
            if(arr[j] == '0')
            {
                arr[j] = '1';
                o_c++;
            }
            else
            {
                arr[j] = '0';
            }
        }
        if(c == 1)
        {
            int cc = 0;
            bool f = true;
            for(int j = 0; j < n; j++)
            {
                if(j == 0)
                {
                    if(arr[j] == '0')
                    {
                        f = false;
                    }
                }
                else if((arr[j] == '1') && (arr[j] != arr[j - 1]))
                {
                    cc++;
                }
            }
            if(f)
            {
                cc += 1;
                cout << cc;
            }
            else
            {
                cout << cc;
            }
        }
        else
        {
            for(int j = 0; j < n; j++)
            {
                if((j < (l - 1)) || (j >= r))
                {
                    if(arr[j] == '1')
                    {
                        o_c++;
                    }
                }
            }
            if(c >= o_c)
            {
                cout << o_c << endl;
            }
        }
    }
    return 0;
}