#!/bin/ruby nums =Hash.new(0) v=('a'..'z').to_a (0..26).each{|i| nums[v[i]]=i } def findp(s,len) count = 0 (0..len-1).each do |i| (i..len-1).each do |j| temp = s[i..j] count = count + 1 if temp == temp.reverse end end return count end def nuewFind(s,len) count=0 vol=Hash.new(0) (s.split('')).each{|i| vol[i]=vol[i]+1 count=count+1 } diff=0 vol.each{|k,v| if v!=0 diff=diff+1 end } vol.each{|k,v| if v==2 count=count+diff end } return count end n,q = gets.strip.split(' ') n = n.to_i q = q.to_i s = gets.strip (0...q).each{|i| l= gets.strip.split(' ').map(&:to_i) if l.length==3 puts nuewFind(s[l[1]..l[2]],l[2]-l[1]+1) else (l[1]..l[2]).each{|j| s[j]=v[(nums[s[j]]+l[3])%26] } end }