class SegmentTree:
    def __init__(self,n,ele=0):
        self.ide_ele = ele
        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num

    def segfunc(self,x,y):
        return x|y

    def init(self,init_val):
        for i in range(len(init_val)):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 

    def update(self,k,x):
        k += self.num-1
        if self.seg[k]==x:
          return 0
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])

    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
      
N,S,Q=int(input()),input(),int(input())
d={'a': 1, 'b': 2, 'c': 4, 'd': 8, 'e': 16, 'f': 32, 'g': 64, 'h': 128, 'i': 256, 'j': 512, 'k': 1024, 'l': 2048, 'm': 4096, 'n': 8192, 'o': 16384, 'p': 32768, 'q': 65536, 'r': 131072, 's': 262144, 't': 524288, 'u': 1048576, 'v': 2097152, 'w': 4194304, 'x': 8388608, 'y': 16777216, 'z': 33554432}

initial=[d[c] for c in list(S)]

ST=SegmentTree(N)
ST.init(initial)

for _ in range(Q):
    typ,a,b=input().split()
    if typ=='1':
        i,c=int(a),d[b]
        ST.update(i-1,c)
    else:
        l,r=int(a)-1,int(b)
        x=bin(ST.query(l,r))[2:]
        print(sum(map(int,list(x)))) class SegmentTree:
    def __init__(self,n,ele=0):
        self.ide_ele = ele
        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num

    def segfunc(self,x,y):
        return x|y

    def init(self,init_val):
        for i in range(len(init_val)):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 

    def update(self,k,x):
        k += self.num-1
        if self.seg[k]==x:
          return 0
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])

    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
       SegmentTree def __init__(self,n,ele=0):
        self.ide_ele = ele
        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num

     __init__ self.ide_ele = ele self.ide_ele self ide_ele ele self.num =2**(n-1).bit_length() self.num self num 2**(n-1).bit_length() 2 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length self.seg=[self.ide_ele]*2*self.num self.seg self seg [self.ide_ele]*2*self.num [self.ide_ele]*2 [self.ide_ele] self.ide_ele self ide_ele 2 self.num self num self self n n ele=0 ele 0 def segfunc(self,x,y):
        return x|y

     segfunc return x|y x|y x y self self x x y y def init(self,init_val):
        for i in range(len(init_val)):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 

     init for i in range(len(init_val)):
            self.seg[i+self.num-1]=init_val[i]
         i range(len(init_val)) range len(init_val) len init_val self.seg[i+self.num-1]=init_val[i] self.seg[i+self.num-1] self.seg self seg i+self.num-1 i+self.num i self.num self num 1 init_val[i] init_val i for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 

     i range(self.num-2,-1,-1) range self.num-2 self.num self num 2 -1 -1 self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) self.seg[i] self.seg self seg i self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) self.segfunc self segfunc self.seg[2*i+1] self.seg self seg 2*i+1 2*i 2 i 1 self.seg[2*i+2] self.seg self seg 2*i+2 2*i 2 i 2 self self init_val init_val def update(self,k,x):
        k += self.num-1
        if self.seg[k]==x:
          return 0
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])

     update k += self.num-1 k self.num-1 self.num self num 1 if self.seg[k]==x:
          return 0
         self.seg[k]==x self.seg[k] self.seg self seg k x return 0 0 self.seg[k] = x self.seg[k] self.seg self seg k x while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])

     k k = (k-1)//2 k (k-1)//2 k-1 k 1 2 self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2]) self.seg[k] self.seg self seg k self.segfunc(self.seg[k*2+1],self.seg[k*2+2]) self.segfunc self segfunc self.seg[k*2+1] self.seg self seg k*2+1 k*2 k 2 1 self.seg[k*2+2] self.seg self seg k*2+2 k*2 k 2 2 self self k k x x def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
       query if q<=p:
            return self.ide_ele
         q<=p q p return self.ide_ele self.ide_ele self ide_ele p += self.num-1 p self.num-1 self.num self num 1 q += self.num-2 q self.num-2 self.num self num 2 res=self.ide_ele res self.ide_ele self ide_ele while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
         q-p>1 q-p q p 1 if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
             p&1 == 0 p&1 p 1 0 res = self.segfunc(res,self.seg[p]) res self.segfunc(res,self.seg[p]) self.segfunc self segfunc res self.seg[p] self.seg self seg p if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
             q&1 == 1 q&1 q 1 1 res = self.segfunc(res,self.seg[q]) res self.segfunc(res,self.seg[q]) self.segfunc self segfunc res self.seg[q] self.seg self seg q q -= 1 q 1 p = p//2 p p//2 p 2 q = (q-1)//2 q (q-1)//2 q-1 q 1 2 if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
         p == q p q res = self.segfunc(res,self.seg[p]) res self.segfunc(res,self.seg[p]) self.segfunc self segfunc res self.seg[p] self.seg self seg p res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q]) res self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q]) self.segfunc self segfunc self.segfunc(res,self.seg[p]) self.segfunc self segfunc res self.seg[p] self.seg self seg p self.seg[q] self.seg self seg q return res res self self p p q q N,S,Q=int(input()),input(),int(input()) N int(input()) int input() input S input() input Q int(input()) int input() input d={'a': 1, 'b': 2, 'c': 4, 'd': 8, 'e': 16, 'f': 32, 'g': 64, 'h': 128, 'i': 256, 'j': 512, 'k': 1024, 'l': 2048, 'm': 4096, 'n': 8192, 'o': 16384, 'p': 32768, 'q': 65536, 'r': 131072, 's': 262144, 't': 524288, 'u': 1048576, 'v': 2097152, 'w': 4194304, 'x': 8388608, 'y': 16777216, 'z': 33554432} d {'a': 1, 'b': 2, 'c': 4, 'd': 8, 'e': 16, 'f': 32, 'g': 64, 'h': 128, 'i': 256, 'j': 512, 'k': 1024, 'l': 2048, 'm': 4096, 'n': 8192, 'o': 16384, 'p': 32768, 'q': 65536, 'r': 131072, 's': 262144, 't': 524288, 'u': 1048576, 'v': 2097152, 'w': 4194304, 'x': 8388608, 'y': 16777216, 'z': 33554432} 'a' 'a' 1 'b' 'b' 2 'c' 'c' 4 'd' 'd' 8 'e' 'e' 16 'f' 'f' 32 'g' 'g' 64 'h' 'h' 128 'i' 'i' 256 'j' 'j' 512 'k' 'k' 1024 'l' 'l' 2048 'm' 'm' 4096 'n' 'n' 8192 'o' 'o' 16384 'p' 'p' 32768 'q' 'q' 65536 'r' 'r' 131072 's' 's' 262144 't' 't' 524288 'u' 'u' 1048576 'v' 'v' 2097152 'w' 'w' 4194304 'x' 'x' 8388608 'y' 'y' 16777216 'z' 'z' 33554432 d[c] for c in list(S) for c in list(S) c list(S) list S for c in list(S) d[c] d c initial=[d[c] for c in list(S)] initial [d[c] for c in list(S)] ST=SegmentTree(N) ST SegmentTree(N) SegmentTree N ST.init(initial) ST.init ST init initial for _ in range(Q):
    typ,a,b=input().split()
    if typ=='1':
        i,c=int(a),d[b]
        ST.update(i-1,c)
    else:
        l,r=int(a)-1,int(b)
        x=bin(ST.query(l,r))[2:]
        print(sum(map(int,list(x)))) _ range(Q) range Q typ,a,b=input().split() typ input().split() ().split () input split a b if typ=='1':
        i,c=int(a),d[b]
        ST.update(i-1,c)
    else:
        l,r=int(a)-1,int(b)
        x=bin(ST.query(l,r))[2:]
        print(sum(map(int,list(x)))) typ=='1' typ '1' i,c=int(a),d[b] i int(a) int a c d[b] d b ST.update(i-1,c) ST.update ST update i-1 i 1 c l,r=int(a)-1,int(b) l int(a)-1 int(a) int a 1 r int(b) int b x=bin(ST.query(l,r))[2:] x bin(ST.query(l,r))[2:] (ST.query(l,r)) bin ST.query(l,r) ST.query ST query l r 2: 2 print(sum(map(int,list(x)))) print sum(map(int,list(x))) sum map(int,list(x)) map int list(x) list x r=int(a)-1,int(b) int(b) r S,Q=int(input()),input(),int(input()) input() S initial=[d[c] for c in list(S)] [d[c] for c in list(S)] initial Q=int(input()),input(),int(input()) int(input()) Q x=bin(ST.query(l,r))[2:] bin(ST.query(l,r))[2:] x c=int(a),d[b] d[b] c N,S,Q=int(input()),input(),int(input()) int(input()) N l,r=int(a)-1,int(b) int(a)-1 l ST=SegmentTree(N) SegmentTree(N) ST i,c=int(a),d[b] int(a) i class SegmentTree:
    def __init__(self,n,ele=0):
        self.ide_ele = ele
        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num

    def segfunc(self,x,y):
        return x|y

    def init(self,init_val):
        for i in range(len(init_val)):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 

    def update(self,k,x):
        k += self.num-1
        if self.seg[k]==x:
          return 0
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])

    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
       class SegmentTree:
    def __init__(self,n,ele=0):
        self.ide_ele = ele
        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num

    def segfunc(self,x,y):
        return x|y

    def init(self,init_val):
        for i in range(len(init_val)):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 

    def update(self,k,x):
        k += self.num-1
        if self.seg[k]==x:
          return 0
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])

    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
       SegmentTree d={'a': 1, 'b': 2, 'c': 4, 'd': 8, 'e': 16, 'f': 32, 'g': 64, 'h': 128, 'i': 256, 'j': 512, 'k': 1024, 'l': 2048, 'm': 4096, 'n': 8192, 'o': 16384, 'p': 32768, 'q': 65536, 'r': 131072, 's': 262144, 't': 524288, 'u': 1048576, 'v': 2097152, 'w': 4194304, 'x': 8388608, 'y': 16777216, 'z': 33554432} {'a': 1, 'b': 2, 'c': 4, 'd': 8, 'e': 16, 'f': 32, 'g': 64, 'h': 128, 'i': 256, 'j': 512, 'k': 1024, 'l': 2048, 'm': 4096, 'n': 8192, 'o': 16384, 'p': 32768, 'q': 65536, 'r': 131072, 's': 262144, 't': 524288, 'u': 1048576, 'v': 2097152, 'w': 4194304, 'x': 8388608, 'y': 16777216, 'z': 33554432} d a,b=input().split() input().split() a typ,a,b=input().split() input().split() typ b=input().split() input().split() b
class SegmentTree:
    def __init__(self,n,ele=0):
        self.ide_ele = ele
        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num

    def segfunc(self,x,y):
        return x|y

    def init(self,init_val):
        for i in range(len(init_val)):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 

    def update(self,k,x):
        k += self.num-1
        if self.seg[k]==x:
          return 0
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])

    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
      
N,S,Q=int(input()),input(),int(input())
d={'a': 1, 'b': 2, 'c': 4, 'd': 8, 'e': 16, 'f': 32, 'g': 64, 'h': 128, 'i': 256, 'j': 512, 'k': 1024, 'l': 2048, 'm': 4096, 'n': 8192, 'o': 16384, 'p': 32768, 'q': 65536, 'r': 131072, 's': 262144, 't': 524288, 'u': 1048576, 'v': 2097152, 'w': 4194304, 'x': 8388608, 'y': 16777216, 'z': 33554432}

initial=[d[c] for c in list(S)]

ST=SegmentTree(N)
ST.init(initial)

for _ in range(Q):
    typ,a,b=input().split()
    if typ=='1':
        i,c=int(a),d[b]
        ST.update(i-1,c)
    else:
        l,r=int(a)-1,int(b)
        x=bin(ST.query(l,r))[2:]
        print(sum(map(int,list(x))))