#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define amfetamin ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const int N = 2005;
ll dp[N][N];
int main()
{
amfetamin;
int n, c, q;
cin >> n >> c >> q;
string s;
cin >> s;

if (c == 1 && n <= 10000)
{
    int l, r;
    cin >> l >> r;
    for (int i = l; i <= r; i++)
    {
        if (s[i] == '1')
            s[i] = '0';
        else
            s[i] = '1';
    }
    int i = 0;
    while (s[i] == '0')
        i++;


}
else
if (c == n)
{
    int ct = 0;
    for (int i = 0; i < n; i++)
        if (s[i] == '1')
            ct++;
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        for (int i = l; i <= r; i++)
        {
            if (s[i] == '1')
            {
                s[i] = '0';
                ct--;
            }
            else
            {
                s[i] = '1';
                ct++;
            }
        }
        cout << ct << endl;

    }
}





}