#include using namespace std; #define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++) #define ll long long int main() { int N, Q; cin >> N >> Q; string S; cin >> S; while(Q--) { int q; cin >> q; if (q == 1) { int x; char c; cin >> x >> c; x--; S[x] = c; } else { int l, r; cin >> l >> r; l--; vector> dp(r-l+1, vector(4, N+1)); dp[0][0] = 0; rep(i, 0, r-l) { rep(j, 0, 4) { rep(k, j, 4) { dp[i+1][k] = min(dp[i+1][k], dp[i][j] + (S[l+i]-'A' == k? 0 : 1)); } } } cout << min(min(dp.back()[0], dp.back()[1]), min(dp.back()[2], dp.back()[3])) << endl; } } }