#include <iostream>
using namespace std;

void zameni(char& x) {
	if (x == '1')
		x = '0';
	else
		x = '1';
}

int minCena(string x, int c) {
	int mincena = 0;
	int pr0 = 0;
	int pr1 = 0;
	int z = 0;
	for (int i = x.length()-1; i >= 0; i--) {
		if (x[i] == '0')
			z++;
		else
			break;
	}

	for (int i = 0; i < x.length()-z; i++) {
		if (x[i] == '1'){
			pr1++;
			if (pr1 > c)
			{
				mincena += pr0;
				pr0 = 0;
			}
		}
		else if(x[i] == '0'){
			if (pr0 == 0 && pr1 == 0)
				continue;
			else if (pr0 <= c-1)
				pr0++;
			else if (pr0 > c-1)
			{
				if (c + pr0 > pr1)
					mincena += pr1;
				else
					mincena += c + pr0;
				pr1 = 0;
				pr0 = 0;
			}
		}
	}
	if (pr1 > 0) {
		if (c + pr0 > pr1)
			mincena += pr1;
		else
			mincena += c + pr0;
	}
	return mincena;
}

int main()
{
	int n, c, q;
	cin >> n >> c >> q;
	string a;
	cin >> a;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		while (l < r) {
			zameni(a[l]);
			l++;
		}
		cout << minCena(a, c) << endl;
	}
}