#include <iostream>

using namespace std;

int main()
{
    int n, c, q;
    string s;
    cin >> n >> c >> q >> s;
    int *l = new int[q + 1];
    int *r = new int[q + 1];
    for(int i = 1; i <= q; i++){
        cin >> l[i];
        cin >> r[i];
    }
    for(int j = 1; j <= q; j++){
        for(int i = l[j] - 1; i < r[j]; i++){
            if(s[i] == '1') s[i] = '0';
            else s[i] = '1';
        }
        if(c == n){
            int uk = 0;
            for(int i = 0; i < n; i++){
                if(s[i] == '1') uk++;
            }
            cout << uk << endl;
        }
        else if(c == 1){
            int uk = 0;
            if(s[0] == '1') uk++;
            for(int i = 1; i < n; i++){
                if(s[i] == '1' && s[i - 1] == '0') uk++;
            }
            cout << uk << endl;
        }
    }
    return 0;
}