#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fi first
#define se second
#define ld long double
#define N_5 100010
#define N_6 1000010
#define N_7 10000010
#define N_8 100000010
#define N_9 1000000010
#define ost 1000000007
#define ldb long double
#define ull unsigned long long
using namespace std;


void solve() {
    int n,c,q;
    cin >> n >> c >> q;
    string s ;
    cin >> s;
    while(q--) {
        int l , r ;
        cin >> l >> r ; l--; r--;
        for (int i = l ; i <= r ; i++ ) {
            if ( s[i] == '1' ) s[i] = '0' ;
            else s[i] = '1';
        }
        int cnt = 0 ;
        for (int i = 0 ; i < n ; i++ ) {
            if (s[i] == '1' ) cnt++;
        }
        cout << cnt << endl ;
    }
} 
 
 
int main () {
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t =1;
    //cin >>t ;
    while(t--) 
        solve();
}