#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,int) sort(a.begin(),a.end(),greater<int>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define up(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define vstart auto startt=chrono::system_clock::now()
#define vend auto endd=chrono::system_clock::now()
#define vvreme chrono::duration<double> vremee=endd-startt
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef string str;

void promeni(char &a){
    if(a=='0') a='1';
    else a='0';
}

void solve(){
    int n,c,q;
    cin>>n>>c>>q;
    str s;
    cin>>s;
    str t=s;
    for(int i=1;i<t.size();i++){
        if(s[i]!=s[i-1]) t[i]='1';
        else t[i]='0';
    }
    if(n==c){

    }else if(c==1){
        int res=0;
        for(int i=0;i<n;i++) if(t[i]=='1') res++;
        while(q--){
            int l,r;
            cin>>l>>r;
            l--,r--;
            if(t[l]=='1') res--;
            else res++;
            if(r<n-1 && t[r+1]=='1') res--;
            else res++;
            promeni(t[l]);
            if(r<n-1) promeni(t[r+1]);
            cout<<res<<"\n";
        }
    }
}

int main(){
    ios;
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}