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++){ int t = in.nextInt(); if(t == 1) { int i = in.nextInt(); int j = in.nextInt(); int z = in.nextInt(); char a[] = s.toCharArray(); for(int x = i; x <= j; x++) a[x]+=z; s = new String(a); //System.out.println(s); } else { int i = in.nextInt(); int j = in.nextInt(); int count = (j-i)+1; for(int x = i; x <= j; x++){ for(int y = x+1; y <= j; y++) { if(isPal(s, i, x, y)) count++; } } System.out.println(count); } } } public static boolean isPal(String s, int i, int x, int y) { String sub = s.substring(i, x+1) + "" + s.charAt(y); //System.out.println(sub); String rev = ""; for(int j = sub.length()-1; j >= 0; j--) rev += sub.charAt(j); if(sub.equals(rev)) return true; return false; } }