#include <iostream>

using namespace std;

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