#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN = 1e9;
const ll mod = 1e9 + 7;

int main()
{
    int n, c, q;
    string s;
    cin >> n >> c >> q >> s;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '1')
            count++;
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        if (c == n)
        {
            for (int i = l; i <= r; i++)
            {
                if (s[i] == '0')
                {
                    s[i] = '1';
                    count++;
                }
                else
                {
                    s[i] = '0';
                    count--;
                }
            }
            cout << count << "\n";
        }
        else if (c == 1)
        {
            for (int i = l; i <= r; i++)
            {
                if (s[i] == '0')
                {
                    s[i] = '1';
                    count++;
                }
                else
                {
                    s[i] = '0';
                    count--;
                }
            }
            int subc = 0, cur = 0;
            int first = -1, last = -1;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == '1')
                {
                    cur++;
                    if (first == -1)
                        first = i;
                    last = i;
                }
                else
                {
                    if (cur > 0)
                        subc++;
                    cur = 0;
                }
            }
            if (cur > 0)
                subc++;
            cout << subc << "\n";
        }
        else
        {
            for (int i = l; i <= r; i++)
            {
                if (s[i] == '0')
                {
                    s[i] = '1';
                    count++;
                }
                else
                {
                    s[i] = '0';
                    count--;
                }
            }
            int subc = 0, cur = 0, notworth = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == '1')
                {
                    cur++;
                }
                else
                {
                    if (cur >= c)
                        subc++;
                    if (cur < c && cur > 0)
                        notworth += cur;
                    cur = 0;
                }
            }
            if (cur > 0)
                subc++;
            cout << subc * c + notworth << "\n";
        }
    }
}