#!/bin/python3 import sys def shift(n, s): s = s % 26 out = ord(n) + s if out > ord('z'): out -= 26 return chr(out) import operator as op def ncr(n, r): r = min(r, n-r) if r == 0: return 1 numer = reduce(op.mul, xrange(n, n-r, -1)) denom = reduce(op.mul, xrange(1, r+1)) return numer//denom def calculate_pali(n): alpha = [0] * 26 for i in range(len(n)): alpha[ord(n[i]) - ord('a')] += 1 total = 0 count = 0 single = 0 double = 0 for i in range(26): if (alpha[i] > 0): count += 1 if (alpha[i] == 1): single += 1 elif (alpha[i] >= 2): double +=1 for i in range(1, double+1): total += (single + (double - i) + 1) * ncr(double, i) total += count return total n,q = input().strip().split(' ') n,q = [int(n),int(q)] s = input().strip() for a0 in range(q): query = [int(x) for x in input().strip().split(' ')] if int(query[0]) == 1: q1, a, b, t = query for i in range(a, b+1): shift(s[i], t) else: q1, a, b = query subset = s[a: b+1] print(calculate_pali(subset)) # your code goes here