from sortedcontainers import SortedList class IndexedSet: """SortedList + prefix sum 用に拡張""" def __init__(self): self.sl = SortedList() self.sums = [] def _recalc(self): # prefix sum を更新 self.sums = [] total = 0 for v in self.sl: total += v self.sums.append(total) def add(self, x): self.sl.add(x) self._recalc() def remove(self, x): self.sl.remove(x) self._recalc() def lower_bound(self, x): return self.sl.bisect_left(x) def prefix_sum(self, r): if r == 0: return 0 if r > len(self.sums): return self.sums[-1] return self.sums[r-1] def encode(s, i): return (ord(s[i]) - ord('a')) * 26 * 26 + (ord(s[i+1]) - ord('a')) * 26 + (ord(s[i+2]) - ord('a')) def solve(): import sys input = sys.stdin.readline N, Q = map(int, input().split()) S = input().strip() state = list(S) indices = [None] * (26*26*26) for i in range(N-2): code = encode(S, i) if indices[code] is None: indices[code] = IndexedSet() indices[code].add(i+1) for _ in range(Q): tmp = input().split() q = int(tmp[0]) if q == 1: k = int(tmp[1]) - 1 x = tmp[2] for j in range(k-2, k+1): if 0 <= j < N-2: c = encode(state, j) indices[c].remove(j+1) state[k] = x for j in range(k-2, k+1): if 0 <= j < N-2: c = encode(state, j) if indices[c] is None: indices[c] = IndexedSet() indices[c].add(j+1) else: l = int(tmp[1]) r = int(tmp[2]) a = tmp[3] code = encode(a, 0) if indices[code] is None: print(0) else: p = indices[code].lower_bound(r) s = indices[code].lower_bound(l) ans = indices[code].prefix_sum(p) - indices[code].prefix_sum(s) ans -= (p - s) * (l - 1) print(ans)