1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;

int n;

int licz(const string &s)
{
    unordered_map<string, int> ilerazy;
    int ile = 1 << n;
    for (int i = 1; i < ile; i++) 
    {
        string nowe;
        for (int j = 0; j < n; j++) 
        {
            if(i & (1 << j))
            {
            	nowe.push_back(s[j]);
            }
        }
        ilerazy[nowe]++;
    }
    int odp = 0;
    for(auto x : ilerazy)
    {
        if(x.second >= 2)
        {
        	odp++;
        }
    }
    //cout << ilerazy.size() << " " << ilerazy.size() - odp << endl;
    return odp;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q;
    cin >> n >> q;
    string s;
    cin >> s;
    cout << licz(s) << endl;
    while(q--)
    {
        int x;
        cin >> x;
        cin >> s[x - 1];
        cout << licz(s) << endl;
    }
    return 0;
}