class SegmentTree:
    def __init__(self,siz,v = 0):
        self.n = 1
        self.v = v
        while self.n < siz: self.n *= 2
        self.node = [self.v]*(2*self.n-1)

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

    def update(self,i,x):
        i += self.n-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
    def query(self,a,b):
        vl = vr = self.v
        a += self.n-1
        b += self.n-1
        while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
        return self.merge(vl,vr)
    
n = int(input())
st = SegmentTree(n)
s = list(input())
def f(c): return 1<<(ord(c) - ord("a"))
for i in range(n): st.update(i,f(s[i]))
q = int(input())
for _ in range(q):
    typ,x,y = input().split()
    if typ == "1":
        i,c = int(x)-1,y
        if s[i] == c: continue
        st.update(i,f(c))
        s[i] = c
    else:
        l,r = int(x)-1,int(y)
        print(bin(st.query(l,r)).count("1")) class SegmentTree:
    def __init__(self,siz,v = 0):
        self.n = 1
        self.v = v
        while self.n < siz: self.n *= 2
        self.node = [self.v]*(2*self.n-1)

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

    def update(self,i,x):
        i += self.n-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
    def query(self,a,b):
        vl = vr = self.v
        a += self.n-1
        b += self.n-1
        while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
        return self.merge(vl,vr)
     SegmentTree def __init__(self,siz,v = 0):
        self.n = 1
        self.v = v
        while self.n < siz: self.n *= 2
        self.node = [self.v]*(2*self.n-1)

     __init__ self.n = 1 self.n self n 1 self.v = v self.v self v v while self.n < siz: self.n *= 2
         self.n < siz self.n self n siz self.node = [self.v]*(2*self.n-1) self.node self node [self.v]*(2*self.n-1) [self.v] self.v self v 2*self.n-1 2*self.n 2 self.n self n 1 self self siz siz v = 0 v 0 def merge(self,x,y): return x | y

     merge self self x x y y def update(self,i,x):
        i += self.n-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
     update i += self.n-1 i self.n-1 self.n self n 1 self.node[i] = x self.node[i] self.node self node i x while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
     i > 0 i 0 i = (i-1)//2 i (i-1)//2 i-1 i 1 2 self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2]) self.node[i] self.node self node i self.merge(self.node[i*2+1],self.node[i*2+2]) self.merge self merge self.node[i*2+1] self.node self node i*2+1 i*2 i 2 1 self.node[i*2+2] self.node self node i*2+2 i*2 i 2 2 self self i i x x def query(self,a,b):
        vl = vr = self.v
        a += self.n-1
        b += self.n-1
        while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
        return self.merge(vl,vr)
     query vl = vr = self.v vl self.v self v = vr = self.v vr self.v a += self.n-1 a self.n-1 self.n self n 1 b += self.n-1 b self.n-1 self.n self n 1 while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
         a < b a b if a & 1 == 0: vl = self.merge(vl,self.node[a])
             a & 1 == 0 a & 1 a 1 0 if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
             b & 1 == 0 b & 1 b 1 0 a //= 2 a 2 b = (b-1)//2 b (b-1)//2 b-1 b 1 2 return self.merge(vl,vr) self.merge(vl,vr) self.merge self merge vl vr self self a a b b n = int(input()) n int(input()) int input() input st = SegmentTree(n) st SegmentTree(n) SegmentTree n s = list(input()) s list(input()) list input() input def f(c): return 1<<(ord(c) - ord("a")) f c c for i in range(n): st.update(i,f(s[i])) i range(n) range n q = int(input()) q int(input()) int input() input for _ in range(q):
    typ,x,y = input().split()
    if typ == "1":
        i,c = int(x)-1,y
        if s[i] == c: continue
        st.update(i,f(c))
        s[i] = c
    else:
        l,r = int(x)-1,int(y)
        print(bin(st.query(l,r)).count("1")) _ range(q) range q typ,x,y = input().split() typ input().split() ().split () input split x y if typ == "1":
        i,c = int(x)-1,y
        if s[i] == c: continue
        st.update(i,f(c))
        s[i] = c
    else:
        l,r = int(x)-1,int(y)
        print(bin(st.query(l,r)).count("1")) typ == "1" typ "1" i,c = int(x)-1,y i int(x)-1 int(x) int x 1 c y if s[i] == c: continue
         s[i] == c s[i] s i c st.update(i,f(c)) st.update st update i f(c) f c s[i] = c s[i] s i c l,r = int(x)-1,int(y) l int(x)-1 int(x) int x 1 r int(y) int y print(bin(st.query(l,r)).count("1")) print bin(st.query(l,r)).count("1") (st.query(l,r)).count (st.query(l,r)) bin st.query(l,r) st.query st query l r count "1" typ,x,y = input().split() input().split() typ y = input().split() input().split() y l,r = int(x)-1,int(y) int(x)-1 l q = int(input()) int(input()) q st = SegmentTree(n) SegmentTree(n) st i,c = int(x)-1,y int(x)-1 i n = int(input()) int(input()) n x,y = input().split() input().split() x class SegmentTree:
    def __init__(self,siz,v = 0):
        self.n = 1
        self.v = v
        while self.n < siz: self.n *= 2
        self.node = [self.v]*(2*self.n-1)

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

    def update(self,i,x):
        i += self.n-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
    def query(self,a,b):
        vl = vr = self.v
        a += self.n-1
        b += self.n-1
        while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
        return self.merge(vl,vr)
     class SegmentTree:
    def __init__(self,siz,v = 0):
        self.n = 1
        self.v = v
        while self.n < siz: self.n *= 2
        self.node = [self.v]*(2*self.n-1)

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

    def update(self,i,x):
        i += self.n-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
    def query(self,a,b):
        vl = vr = self.v
        a += self.n-1
        b += self.n-1
        while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
        return self.merge(vl,vr)
     SegmentTree c = int(x)-1,y y c s = list(input()) list(input()) s def f(c): return 1<<(ord(c) - ord("a")) def f(c): return 1<<(ord(c) - ord("a")) f r = int(x)-1,int(y) int(y) r
class SegmentTree:
    def __init__(self,siz,v = 0):
        self.n = 1
        self.v = v
        while self.n < siz: self.n *= 2
        self.node = [self.v]*(2*self.n-1)

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

    def update(self,i,x):
        i += self.n-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.merge(self.node[i*2+1],self.node[i*2+2])
    
    def query(self,a,b):
        vl = vr = self.v
        a += self.n-1
        b += self.n-1
        while a < b:
            if a & 1 == 0: vl = self.merge(vl,self.node[a])
            if b & 1 == 0: vr = self.merge(vr,self.node[b-1])
            a //= 2
            b = (b-1)//2
        return self.merge(vl,vr)
    
n = int(input())
st = SegmentTree(n)
s = list(input())
def f(c): return 1<<(ord(c) - ord("a"))
for i in range(n): st.update(i,f(s[i]))
q = int(input())
for _ in range(q):
    typ,x,y = input().split()
    if typ == "1":
        i,c = int(x)-1,y
        if s[i] == c: continue
        st.update(i,f(c))
        s[i] = c
    else:
        l,r = int(x)-1,int(y)
        print(bin(st.query(l,r)).count("1"))