import bisect INF = 999 N,Q = map(int, input().split()) S = list(input()) dic = {"A":0,"B":1,"C":2,"D":3} for i in range(N): S[i] = dic[S[i]] def LIS(L): lis = [INF for _ in range(len(L)+1)] for l in L: lis[bisect.bisect_right(lis,l)] = l return len(L)-bisect.bisect_left(lis, INF) for _ in range(Q): query = list(input().split()) if query[0]=="1": x,c = query[1:] x = int(x)-1 S[x] = dic[c] else: l,r = query[1:] l = int(l) r = int(r) l -= 1 r -= 1 print(LIS(S[l:r+1]))