#include <bits/stdc++.h>
using namespace std;
int n, q, x, y , brU, br;
string s;

int main(){
    cin >> n >> q >> s;

    for(int i = 0; i < n; i++)
        if(s[i] == '?')
            brU++;

    for(int k = 1; k <= q; k++){
        cin >> x >> y;
        br = 0;

        if(brU == 0){
            for(int i = x-1; i <= y; i++){
                if(s[i] == '6' && s[i+1] == '7')
                    br++;
            }
            cout << br <<'\n';
        }
    }


    return 0;
}