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
#include <bits/stdc++.h>
using namespace std;

int n; string s;
long long f()
{
  unordered_map <string,int> cnt;
  for(int mask=1; mask<(1<<n); mask++)
  {
    string act = "";
    for(int i=0; i<n; i++) if(mask & (1<<i)) act += s[i];
    cnt[act]++;
  }
  
  int ret=0;
  for(auto &x : cnt) if(x.second >= 2) ret++;
  return ret;
}

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

  int q; cin >> n >> q >> s;
  cout << f() << '\n';
  while(q--)
  {
    int i; char c; cin >> i >> c; s[i-1]=c;
    cout << f() << '\n';
  }
}