#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, c, q, l, r;
    string s;

    cin >> n >> c >> q;
    cin >> s;

    if(c == n)
    {
        int br = 0;

        for(int i = 0; i < n; ++i) if(s[i] == '1') br++;

        for(int i = 0; i < q; ++i)
        {
            cin >> l >> r;

            for(int j = l - 1; j < r; ++j)
            {
                if(s[j] == '0')
                {
                    s[j] = '1';
                    br++;
                }
                else
                {
                    s[j] = '0';
                    br--;
                }
            }

            cout << br << endl;
        }
    }
    else if(c == 1)
    {
        for(int i = 0; i < q; ++i)
        {
            cin >> l >> r;

            for(int j = l - 1; j < r; ++j)
            {
                if(s[j] == '0') s[j] = '1';
                else s[j] = '0';
            }

            int br = 0;
            char c = s[0];

            if(c == '1') br++;

            for(int j = 1; j < n; ++j)
            {
                if(c != s[j])
                {
                    c = s[j];
                    if(c == '1') br++;
                }
            }

            cout << br << endl;
        }
    }

    return 0;
}