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 a0 = 0; a0 < q; a0++){ // your code goes here int typeQ = in.nextInt(); if(typeQ == 2){ int i = in.nextInt(); int j = in.nextInt(); String temp = s.substring(i, j+1); String[] output = subSequences(temp); int count = 0; for(int z = 0; z < output.length; z++){ if(checkPalindrome(output[z])){ count++; } } System.out.println(count); }else if(typeQ == 1){ int i = in.nextInt(); int j = in.nextInt(); int t = in.nextInt(); String temp = s.substring(i, j+1); String replace = ""; for(int r = i; r <= j; r++){ replace += (char)(((int)s.charAt(r) - (int)'a' +1 +t)%26 + (int)'a' -1); } String newS = s.substring(0, i) + replace + s.substring(j+1); } } } public static String[] subSequences(String input){ if(input.length() == 0){ String[] output = {""}; return output; } String[] smallOutput = subSequences(input.substring(1)); String[] output = new String[2 * smallOutput.length]; int k = 0; for(int i = 0; i < smallOutput.length; i++){ output[k++] = smallOutput[i]; } for(int i = 0; i < smallOutput.length; i++){ // output[i + smallOutput.length] = input.charAt(0) + smallOutput[i]; output[k++] = input.charAt(0) + smallOutput[i]; } return output; } public static boolean checkPalindrome(String str){ if(str.length() == 0){ return false; } for(int i = 0; i < str.length()/2; i++){ if(str.charAt(i) != str.charAt(str.length()-1-i)){ return false; } } return true; } public static int countPalindrome(String str){ //int add = str.length(); //odd length int count = str.length(); for(int i = 0; i < str.length(); i++){ for(int j = 1; j <= (str.length()-1)/2; j++){ if(i-j < 0 || i+j >= str.length()){ break; } if(str.charAt(i-j) != str.charAt(i+j)){ break; }else{ count++; } } } //even length for(int i = 0; i < str.length()-1; i++){ for(int j = 0; j <= (str.length()-2)/2; j++){ if(i-j < 0 || i+j+1 >= str.length()){ break; } if(str.charAt(i-j) != str.charAt(i+j+1)){ break; }else{ count++; } } } return count; } }