///sat
#include <chrono>
using namespace std::chrono;
#define vremestart auto start = high_resolution_clock::now();
#define vremeend auto stop = high_resolution_clock::now();
#define vremeispis auto duration = duration_cast<microseconds>(stop - start); cout << duration.count() << endl;
///sat
#define here cerr<<"here\n";
#define popcount(x) __builtin_popcount(x) ///broji broj bitova
#include <bits/stdc++.h>
#define mode 998244353
#define gcd __gcd
#define ld long double
#define ll long long
#define ull unsigned long long
#define llinf 1000000000000000000LL
#define iinf 2000000000
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define th third
#define fo fourth
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
#define maxn 200005
int n,c,q;
int a[maxn];
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >>  c >> q;
    string s;
    cin >> s;
    int one = 0;
    for(int i = 1;i<=n;i++){
        a[i] = s[i-1]-'0';
        one+=a[i];
    }
    if(c==n){
        while(q--){
            int l,r;
            cin >> l >> r;
            for(int i = l;i<=r;i++){
                if(a[i]==0) one++;
                else one--;
                a[i] = !a[i];
            }
            cout<<one<<"\n";
        }
        return 0;
    }
    if(c==1){
        while(q--){
            int l,r;
            cin >> l >> r;
            for(int i = l;i<=r;i++){
                a[i] = !a[i];
            }
            int k = 0;
            int e = 0;
            for(int i = 1;i<=n;i++){
                if(a[i]==1){
                    if(e==0) k++;
                    e = 1;
                }else e = 0;
            }
            cout<<k<<"\n";
        }
        return 0;
    }
    while(q--){
        int l,r;
        cin >> l >> r;
        cout<<1;
    }
    return 0;
}