#include <iostream>
#include <vector>

using namespace std;

int n;

int price(string &s,int l,int r, int &bj) {
	while (l < r) {
		if (s[l] == '0') {
			s[l] = '1';
			bj++;
		}
		else {
			s[l] = '0';
			bj--;
		}
		l++;
	}
	return bj;
}

int main()
{
	int c, q;
	cin >> n >> c >> q;
	string s;
	cin >> s;
	vector<pair<int, int>> v(q);
	for (int i = 0;i < q;i++) {
		cin >> v[i].first >> v[i].second;
		v[i].first--;
	}
	if (c == n) {
		int bj = 0;
		for (int i = 0;i < n;i++)
			if (s[i] == '1')bj++;
		for (int i = 0;i < q;i++) {
			bj = price(s, v[i].first, v[i].second, bj);
			cout << bj << endl;
        }
	}
	else
		for (int i = 0;i < q;i++)
			cout << i << endl;
}