#include <bits/stdc++.h>
// #define int long long
#define endl '\n'
using namespace std;
const int N = 1e5+5;
int q,n;
string s;
char c;
int cnt,x;
signed main(){
ios::sync_with_stdio(0);
cin.tie(NULL);
cin >> n >> q >> s;
int si = s.size();
s = '-' + s;
for(int i = 1; i < si-1; i++){
if(s[i] != 'a' || s[i+1] != 'b' || s[i+2] != 'c')
continue;
cnt++;
}
while(q--){
cin >> x >> c;
if(s[x] == c){
cout << cnt << endl;
continue;
}
if(x < si-1 && s[x] == 'a' && s[x+1] == 'b' && s[x+2] == 'c'
|| x > 1 && x < si && s[x-1] == 'a' && s[x] == 'b' && s[x+1] == 'c'
|| x > 2 && s[x-2] == 'a' && s[x-1] == 'b' && s[x] == 'c'){
cnt--,s[x] = c;;
cout << cnt << endl;
continue;
}
if(c == 'a' && x < si-1 && s[x+1] == 'b' && s[x+2] == 'c') cnt++;
else if(c == 'b' && x > 1 && x < si && s[x-1] == 'a' && s[x+1] == 'c') cnt++;
else if(c == 'c' && x > 2 && s[x-2] == 'a' && s[x-1] == 'b') cnt++;
s[x] = c;
cout << cnt << endl;
// cout << s << endl;
}
return 0;
}
切不了橙题是不是可以退役了