{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString as BR
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as IS
import qualified Data.ByteString.Internal as B
import Control.Monad
import Foreign.ForeignPtr
import Foreign.Storable
main = do
    _ <- B.getLine
    str@(B.PS fptr _ _) <- B.getLine
    numQueries <- readLn
    replicateM_ numQueries $ do
        [typ, p, q] <- B.words <$> B.getLine 
        case typ of
            "1" -> do
                let i = read $ B.unpack p
                let v = BR.head q
                withForeignPtr fptr $ \ptr -> pokeElemOff ptr (i - 1) v
            "2" -> do
                let i = read $ B.unpack p
                let j = read $ B.unpack q
                print $ IS.size $ IS.fromList $ map fromEnum
                    $ B.unpack (B.take (j - i + 1) $ B.drop (i - 1) str)