process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// function main() { var n_temp = readLine().split(' '); var n = parseInt(n_temp[0]); var q = parseInt(n_temp[1]); var s = readLine(); var a = []; var type, i, j, t, c; for(var a0 = 0; a0 < q; a0++){ n_temp = readLine().split(' '); type = parseInt(n_temp[0]); if (type == 2) { i = parseInt(n_temp[1]); j = parseInt(n_temp[2]); } else { i = parseInt(n_temp[1]); j = parseInt(n_temp[2]); t = parseInt(n_temp[3]); for(var k = i; k <= j; k++) for (var l = 0; l < t % 26; l++) { console.error(s[k]); s = s.replaceAt(k, nextChar(s[k])); } continue; } // do stuff with type 2 for(var k = 0; k < 26; k++) a[k] = 0; for(var k = i; k <= j; k++) a[s.charCodeAt(k) - 97]++; //console.error(s.charCodeAt(k)); //console.error(a); c = 0; for(var k = 0; k < 26; k++) { c += a[k]*a[k]; } console.log(c); } console.error(s); } String.prototype.replaceAt=function(index, character) { return this.substr(0, index) + character + this.substr(index+character.length); } function nextChar(c) { return String.fromCharCode(c.charCodeAt(0) + 1); }