#include using namespace std; int N, Q; char a[100005]; int ap[100005][30]; int cnt[30]; void precalc() { for(int i = 1; i <= N; ++i) for(int c = 0; c <= 27; ++ c) ap[i][c] = ap[i-1][c] + ((a[i] - 'a') == c); } const int MOD = 1000000007; long long lgput(long long A,long long B) { long long X1 = A, X2 = 1; if(B == 0) return 1; if(B == 1) return A % MOD; while(B) if(B&1){ B^= 1; X2 = (X1 * X2)%MOD; } else { B >>=1; X1 = (X1 * X1)%MOD; } return X2; } void perform2(int left, int right) { memset(cnt,0,sizeof(cnt)); for(int i = 0; i <= 27; ++i) cnt[i] = ap[right][i] - ap[left - 1][i]; } void perform1(int left, int right, int c) { for(int i = left; i <= right; ++i) a[i] = ((a[i] - 'a' + c) % 26 + 'a'); } void perform2brut(int left, int right) { memset(cnt,0,sizeof(cnt)); for(int i = left; i <= right; ++i) cnt[(a[i] - 'a')] ++; } int apare[30]; char ch[100]; int cntr = 0, start; bool valid() { int cate = 0; int impare = 0; for(int i = 0; i <= 27; ++i){ if(apare[i] % 2 == 1) ++impare; if(apare[i]) ++cate; } if(cate && (impare == 0 || impare == 1) ) return true; return false; } void backt(int k) { if(k >= start) return; apare[ch[k] - 'a']++; if(valid()) ++cntr; backt(k+1); apare[ch[k] - 'a']--; backt(k+1); } long long numara(int left, int right) { ///cout << endl << "PLM" << endl; memset(apare,0,sizeof(apare)); start = 1; ch[0] = '#'; for(int i = left; i <= right; ++i) ch[start++] = a[i]; ch[start] = 0; ///cout << ch << endl; cntr = 0; backt(1); return cntr; } int main() { ///freopen("D.in","r",stdin); cin >> N >> Q; cin >> (a + 1); a[0] = '#'; ///cerr << a; precalc(); bool vazut1 = false; for(int i = 1 ; i <= Q; ++i) { int tip, va, vb, c; cin >> tip; if(tip == 2) { cin >> va >> vb; ++va; ++vb; cout << numara(va,vb) << "\n"; } else{ vazut1 = true; cin >> va >> vb >> c; ++va; ++vb; perform1(va, vb, c); } // perform2(a, b); } return 0; }