#include <bits/stdc++.h>

#define pb push_back

using namespace std;

void tst1_3(int n, int c, int q, string s) {

    int cnt[n];
    for(int i = 0; i < n; i++) {
        cnt[i] = (i ? cnt[i - 1] : 0);
        if(s[i] == '1')
            cnt[i]++;
    }

    while(q--) {
        int l, r;
        cin >> l >> r;
        l--; r--;

        int br1 = cnt[r] - (l ? cnt[l - 1] : 0);
        cout << cnt[n - 1] - br1 + (r - l + 1 - br1) << endl;
    }
}

void tst4_5(int n, int c, int q, string s) {

    vector<int> elem, pos;
    for(int i = 0; i < n; i++) {
        int x = s[i] - '0';
        if(i == 0 || s[i] != s[i - 1]) {
            elem.pb(x);
            pos.pb(i);
        }
    }

    vector<int> cnt;
    for(int i = 0; i < elem.size(); i++) {
        int x = (i ? cnt[i - 1] : 0);
        if(elem[i] == 1)
            x++;
        
        cnt.pb(x);
    }

    while(q--) {
        int l, r;
        cin >> l >> r;
        l--; r--;

        int a = upper_bound(pos.begin(), pos.end(), l) - pos.begin() - 1,
            b = upper_bound(pos.begin(), pos.end(), r) - pos.begin() - 1;

        if(a == b) {
            int sol = cnt[cnt.size() - 1];
            if(elem[a] == 0) {
                sol++;

                if(pos[a] == 0 && pos.size() == 1) {
                    cout << 1 << endl;
                    continue;
                }

                if(r != n - 1 && r == pos[b + 1] - 1)
                    sol--;
                if(l != 0 && l == pos[a])
                    sol--;
                cout << sol << endl;
            } else {
                if(l == pos[a] && (r == n - 1 || r == pos[b + 1] - 1)) {
                    cout << sol - 1 << endl;
                    continue;
                }
                if(l == pos[a] || (r == n - 1 || r == pos[b + 1] - 1)) {
                    cout << sol << endl;
                    continue;
                }
                cout << sol + 1 << endl;
            }
            continue;
        }

        int br = cnt[b - 1] - cnt[a];
        int ans = cnt[cnt.size() - 1] - br + ((b - 1) - (a + 1) + 1 - br);

        if(elem[a] == 0 && (l == 0 || l != pos[a]))
            ans++;
        if(elem[b] == 0 && (r == n - 1 || r != pos[b + 1] - 1))
            ans++;
        cout << ans << endl;
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, c, q;
    string s;
    cin >> n >> c >> q >> s;

    if(c == n) {
        tst1_3(n, c, q, s);
        return 0;
    } else if(c == 1) {
        tst4_5(n, c, q, s);
        return 0;
    }
    return 0;
}