#include <bits/stdc++.h>

using namespace std;
void bestComb(vector<int> niz, int *lev, int *des){
        int cur;
        int m = niz.size();
        int k = 0;
        *lev = niz[0];
        *des = niz[m-1];
        int t = m-1;
        for (int i = 1; i < m-1; i++){

            cur = niz[i] - niz[k] - 1 - (i-k-1); //br 0 izmedju keceva
            if(cur > i-k && i < t){
                *lev = niz[i];
                k = i;
            }
            cur = niz[t] - niz[t-i] - 1 - (i-1);
            if(cur >  i && t-i > k){
                *des = niz[t-i];
                t = t - i;
            }
        }
}

int main()
{
    int n, c, q, l, r, br1, m, cur, res, lev, des, br0;
    vector<int> niz;
    string s, x;
    scanf("%d %d %d", &n, &c, &q);
    cin >> s;
    while(q--){
        res = 0;
        scanf("%d %d", &l, &r);
        for(int i = l-1; i < r; i++){
            if(s[i] == '0') s[i] = '1';
            else s[i] = '0';
        }

        for (int i = 0; i < n; i++){
            if(s[i] == '1'){
                niz.push_back(i);
            }
        }

        x = s;

        while(true){
            bestComb(niz, &lev, &des);
            br1 = 0;
            br0 = 0;
            for (int i = lev; i <= des; i++){
                if(s[i] == '1') ++br1;
                else ++br0;
            }
            if(c < (br1 - br0)){
                for (int i = lev; i <= des; i++){
                    if(x[i] == '1') x[i] = '0';
                    else x[i] = '1';
                }
                res += c;
                niz.clear();
                for (int i = 0; i < n; i++){
                    if(x[i] == '1'){
                        niz.push_back(i);
                    }
                }

            }
            else break;

        }
        br1 = 0;
        for (int i = 0; i < n; i++){
            if(x[i] == '1') br1++;
        }
        res += br1;

        //for (int i = 0; i < levi.size(); i++){
        cout << res << endl;
       // }
       niz.clear();

    }

    return 0;
}