#!/bin/python import sys from itertools import permutations n,q = raw_input().strip().split(' ') n,q = [int(n),int(q)] s = list(raw_input().strip()) for a0 in xrange(q): a = map(int, raw_input().strip().split(' ')) if a[0]==1: for i in range(a[1],a[2]+1): s[i]=chr(97+((ord(s[i])-97+a[3])%26)) if a[0]==2: count = a[2]-a[1]+1 for i in range(2,a[2]-a[1]+2): p = list(permutations(s[a[1]:a[2]+1],i)) count += len(set(filter(lambda x: ''.join(x)==''.join(x[::-1]),p))) print count