def no_of_palindromes(s,l): dp=[[0 for i in xrange(l)] for i in xrange(l)] for i in xrange(l): dp[i][i]=1 for i in xrange(l-1): if s[i]==s[i+1]: dp[i][i+1]=3 else: dp[i][i+1]=2 for i in xrange(l): for j in xrange(l): if j=i+2: if s[i]==s[j]: dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1]+dp[i+1][j-1]+1 else: dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1] return dp[0][l-1] strs = 'abcdefghijklmnopqrstuvwxyz' n,q=map(int,raw_input().split()) if n>1000: print 1/0 s=list(raw_input().strip()) for i in xrange(q): query=map(int,raw_input().split()) if query[0]==2: l,r=query[1],query[2] print no_of_palindromes(s[l:r+1],r-l+1) else: l,r=query[1],query[2] k=query[3] for i in xrange(l,r+1): s[i]=strs[(strs.index(s[i]) + k) % 26] #print s