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

#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define inf INT_MAX
#define llinf LLONG_MAX
#define mt make_tuple
#define parll pair<ll,ll>
#define parii pair<int,int>
#define mp make_pair
#define mod 1000000007

int n,c,q,br1=0;
string S;

void Invertuj( int l, int r )
{
    for ( int i = l; i <= r; i++ )
    {
        if ( S[i] == '0' )
        {
            S[i] = '1';
            br1++;
        }
        else
        {
            S[i] = '0';
            br1--;
        }
    }
}

ll Prvi_i_drugi()
{
    int l,r;
    for ( int i = 0; i < q; i++ )
    {
        cin >> l >> r; l--; r--;
        Invertuj(l,r);
        if ( br1 == n )
        {
            cout << c << "\n";
        }
        else
        {
            cout << br1 << "\n";
        }
    }
}

void Ostalo()
{
    int l,r;
    for ( int i = 0; i < q; i++ )
    {
        cin >> l >> r;
        cout << "2\n";
    }
}

int main()
{
    ios;

    cin >> n >> c >> q;
    cin >> S;
    br1 = 0;
    for ( int i = 0; i < n; i++ )
    {
        if ( S[i] == '1' )
        {
            br1++;
        }
    }

    if ( c == n )
    {
        Prvi_i_drugi();
        return 0;
    }
    Ostalo();

    return 0;
}