#include #include using mint = atcoder::static_modint<998244353>; //using mint = atcoder::static_modint<1000000007>; using namespace std; using namespace atcoder; using ld = long double; using ll = long long; #define mp(a,b) make_pair(a,b) #define rep(i,s,n) for(int i=s; i dx{1,0,-1,0},dy{0,1,0,-1}; struct P{ int a[4][4]; P(){ rep(i,0,4)rep(j,0,4)a[i][j]=0; } }; P convert(char c){ P z; rep(i,0,4)rep(j,i,4){ if(i<=c-'A' && c-'A'<=j)z.a[i][j]=0; else z.a[i][j]=1; } return z; } P op(P x,P y){ P z; rep(i,0,4)rep(j,i,4)z.a[i][j]=1e9; rep(i,0,4)rep(j,i,4)rep(k,j,4){ z.a[i][k]=min(z.a[i][k],x.a[i][j]+y.a[j][k]); } return z; } P e(){return P();} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,Q;cin >> n >> Q; string s;cin >> s; segtree seg(n); rep(i,0,n)seg.set(i,convert(s[i])); vector out; rep(q,0,Q){ int t;cin >> t; if(t==1){ int x;cin >> x; char c;cin >> c; seg.set(x-1,convert(c)); continue; } int l,r; cin >> l >> r; l--; auto p=seg.prod(l,r); out.push_back(p.a[0][3]); } for(auto x:out)cout << x << "\n"; }