//Luka Mitrovic
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <chrono>
using namespace std;

int main() {
	
	int l[20005];
	int r[20005];
	bool niz[20006];
	string s;
	int n,c,q;
	cin >> n >> c >> q;
	cin >> s;

	for (int i = 0; i < q; i++) {
		cin >> l[i] >> r[i];
	}

	int jedinice = 0;
	int nule = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == '1') {
			niz[i] = true;
			jedinice++;
		} else {
			niz[i] = false;
		}
	}
	nule = n - jedinice;
	int ans;
	//cout << jedinice << endl;

	if (c == n) {
		for (int i = 0; i < q; i++) {
			for (int j = l[i]-1; j < r[i]; j++) {
				niz[j] = !niz[j];
				if (niz[j])
					jedinice++;
				else
					jedinice--;
				//cout << niz[j];
			}
			cout << jedinice << endl;
		}
	} else {
		for (int i = 0; i < q; i++) {
			for (int j = l[i]-1; j < r[i]; j++) {
				niz[j] = !niz[j];
				if (niz[j])
					jedinice++;
				else
					jedinice--;
				//cout << niz[j];
			}
			nule = n - jedinice;
			cout << min(c + nule, jedinice) << endl;
		}
	}

}