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

int CalCost(std::string s,int cost) {
    int c = std::count(s.begin(), s.end(), '1');
    if (c <= cost) {
        return c;
    }
    else {
        int b = 0,e = s.length() - 1;
        while (s[b] == '0') ++b;
        while (s[e] == '0') --e;
        c = std::count(s.begin() + b, s.begin() + e, '1');
        if (c >= (e - b - c + cost)) {
            return (e - b - c + cost);
        }
        else {
            return 0;
        }
    }
}

int main()
{
    int N, C, Q; std::cin >> N >> C >> Q;
    std::string s; std::cin >> s;
    std::vector<std::pair<int, int>>v(Q);
    for (auto& i : v)std::cin >> i.first >> i.second;
    for (const auto& i : v) {
        for (int j = i.first - 1; j < i.second; ++j) {
            if (s[j] == '0') s[j] = '1';
            else s[j] = '0';
        }
        std::cout << CalCost(s,C) << std::endl;
    }
}