read -r N
read -r S
read -r Q

#echo ${N} ${S} ${Q}

for c in $(echo ${S} | sed 's|\(.\)|\1 |g'); do
        echo ${c}
done > e.tmp

cnt=0
while [ ${Q} -gt ${cnt} ]; do
        read -r query
        #echo ${query}
        que=(${query})
        #echo ${que[@]}
        if [ ${que[0]} -eq 1 ]; then
                i=${que[1]}
                c=${que[2]}
                sed -i "${i}s/./${c}/" e.tmp
        else
                l=${que[1]}
                r=${que[2]}
                head -n${r} e.tmp | tail -n$((${r} - ${l} + 1)) | sort | uniq | wc -l
        fi

        cnt=$((${cnt} + 1))
        #echo "==="
done

~                                                           