import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int q = in.nextInt(); String s = in.next(); for(int l = 0;l < q; l++){ int a = in.nextInt(); if(a == 1){ int x = in.nextInt(); int y = in.nextInt(); int z = in.nextInt(); String e = ""; String a1 = s.substring(0,x); String a2 = s.substring(y+1); for(int i = x; i<=y;i++){ char g = s.charAt(i); int b = z%26; char u = (char)((int)g + b); e += u; } s = a1 + e+a2; }else if(a == 2){ int j = in.nextInt(); int k = in.nextInt(); String s1 = s.substring(j,k+1); int ans = call(s1); System.out.println(ans); } } } public static int call(String s1){ int n = s1.length(); int store[][] = new int[n+1][n+1]; for(int i=0;i<=n;i++) { for(int j=0;j<=n;j++) { if(i==j) { store[i][j] = 1; } else{ store[i][j] = 0; } } } for(int len=2;len<=n;len++) { for(int i=1;i<=n;i++) { int j=i+len-1; if(j>n) continue; if(s1.charAt(i-1) == s1.charAt(j-1)) { store[i][j] = store[i][j-1]+store[i+1][j]+1; } else { store[i][j] = store[i][j-1]+store[i+1][j]-store[i+1][j-1]; } } } return store[1][n]; } }