#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <numeric>
#include <map>
using namespace std;
const int N = (1 << 18) + 5;
int t[N];
void update(int v, string & s) {
    if (2 * v >= s.size())
        t[v] = (s[v] != '0') + (s[v] != '1');
    else {
        t[v] = 0;
        if (s[v] != '0')
            t[v] += t[2 * v];
        if (s[v] != '1')
            t[v] += t[2 * v + 1];
    }
}
void build(int v, string & s, int tl, int tr) {
    if (tl < tr) {
        int md = (tl + tr) / 2;
        build(2 * v, s, tl, md);
        build(2 * v + 1, s, md + 1, tr);
    }
    update(v, s);
}
void change(int i, char c, string & s) {
    s[i] = c;
    while (i) {
        update(i, s);
        i /= 2;
    }
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int k, q;
    string s;
    cin >> k >> s >> q;
    s.push_back(' ');
    reverse(s.begin(), s.end());
    build(1, s, 1, 1 << (k - 1));
    while (q--) {
        int i;
        char c;
        cin >> i >> c;
        change(s.size() - i, c, s);
        cout << t[1] << '\n';
    }
    return 0;
}