#include <bits/stdc++.h>

using namespace std;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, q;
    cin >> n >> q;

    string board;
    cin >> board;
    int counted = count(board.begin(), board.end(), '?');
    if (counted == n) {
        for (int i = 0; i < q; ++i) {
            int l, r;
            cin >> l >> r;
            int chunk_size = r-l+1;
            cout << chunk_size / 2 << "\n";
        }
    }
}