#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	int n, c, q;
	std::string str;
	std::cin >> n >> c >> q >> str;

	std::vector<std::pair<int, int>> promene(q);	
	for (auto& p : promene)	
		std::cin >> p.first >> p.second;

	for (int i = 0; i < q; ++i)
	{		
		for (int j = promene[i].first - 1; j < promene[i].second; ++j)
			str[j] = (str[j] == '0' ? '1' : '0');

		int c1, c2;
		int b = 0;
		int e = str.size() - 1;
		for (;b != str.size() && str[b] == '0'; ++b);
		for (;e != -1 && str[e] == '0'; --e);
		c1 = c + std::count(str.begin() + b, str.begin() + e + 1, '0');
		c2 = std::count(str.begin(), str.end(), '1');

		if (c1 < c2)
			std::cout << c1 << '\n';
		else
			std::cout << c2 << '\n';
	}

	return 0;
}