#include <iostream>

using namespace std;
int n, c, q;
    int l[1000000];
    int r[1000000];
    string s;
int main()
{
    
    cin >> n >> c >> q;
    cin >> s;
    int kolicina;
    for (int i = 0; i < q; i++)
    {
        kolicina = 0;
        cin >> l[i] >> r[i];
        for (int j = l[i]; j <= r[i]; j++)
        {
            if (s[j-1] == '1')
            {
                s[j - 1] = '0';
            }
            else
            {
                s[j - 1] = '1';
            }
        }
        
        for (int t = 0; t < n; t++)
        {
            if (s[t]=='1')
            {
                kolicina++;
            }
        }
        cout << kolicina;
    }
}