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

    def update(self,i,x):
        i += self.siz-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.node[i*2+1] | self.node[i*2+2]
    
    def query(self,a,b,k=0,l=0,r=-1):
        if r < 0: r = self.siz
        if r <= a or b <= l: return 0
        if a <= l and r <= b: return self.node[k]
        vl = self.query(a,b,k*2+1,l,(l+r)//2)
        vr = self.query(a,b,k*2+2,(l+r)//2,r)
        return 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,n):
        self.siz = 1
        while self.siz < n: self.siz *= 2
        self.node = [0]*(2*self.siz-1)

    def update(self,i,x):
        i += self.siz-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.node[i*2+1] | self.node[i*2+2]
    
    def query(self,a,b,k=0,l=0,r=-1):
        if r < 0: r = self.siz
        if r <= a or b <= l: return 0
        if a <= l and r <= b: return self.node[k]
        vl = self.query(a,b,k*2+1,l,(l+r)//2)
        vr = self.query(a,b,k*2+2,(l+r)//2,r)
        return vl | vr
     SegmentTree def __init__(self,n):
        self.siz = 1
        while self.siz < n: self.siz *= 2
        self.node = [0]*(2*self.siz-1)

     __init__ self.siz = 1 self.siz self siz 1 while self.siz < n: self.siz *= 2
         self.siz < n self.siz self siz n self.node = [0]*(2*self.siz-1) self.node self node [0]*(2*self.siz-1) [0] 0 2*self.siz-1 2*self.siz 2 self.siz self siz 1 self self n n def update(self,i,x):
        i += self.siz-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.node[i*2+1] | self.node[i*2+2]
    
     update i += self.siz-1 i self.siz-1 self.siz self siz 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.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.node[i*2+1] | self.node[i*2+2] self.node[i] self.node self node i self.node[i*2+1] | self.node[i*2+2] 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,k=0,l=0,r=-1):
        if r < 0: r = self.siz
        if r <= a or b <= l: return 0
        if a <= l and r <= b: return self.node[k]
        vl = self.query(a,b,k*2+1,l,(l+r)//2)
        vr = self.query(a,b,k*2+2,(l+r)//2,r)
        return vl | vr
     query if r < 0: r = self.siz
         r < 0 r 0 if r <= a or b <= l: return 0
         r <= a or b <= l r <= a r a b <= l b l if a <= l and r <= b: return self.node[k]
         a <= l and r <= b a <= l a l r <= b r b vl = self.query(a,b,k*2+1,l,(l+r)//2) vl self.query(a,b,k*2+1,l,(l+r)//2) self.query self query a b k*2+1 k*2 k 2 1 l (l+r)//2 l+r l r 2 vr = self.query(a,b,k*2+2,(l+r)//2,r) vr self.query(a,b,k*2+2,(l+r)//2,r) self.query self query a b k*2+2 k*2 k 2 2 (l+r)//2 l+r l r 2 r return vl | vr vl | vr vl vr self self a a b b k=0 k 0 l=0 l 0 r=-1 r -1 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" n = int(input()) int(input()) n y = input().split() input().split() y s = list(input()) list(input()) s c = int(x)-1,y y c r = int(x)-1,int(y) int(y) r typ,x,y = input().split() input().split() typ st = SegmentTree(n) SegmentTree(n) st q = int(input()) int(input()) q class SegmentTree:
    def __init__(self,n):
        self.siz = 1
        while self.siz < n: self.siz *= 2
        self.node = [0]*(2*self.siz-1)

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

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

    def update(self,i,x):
        i += self.siz-1
        self.node[i] = x
        while i > 0:
            i = (i-1)//2
            self.node[i] = self.node[i*2+1] | self.node[i*2+2]
    
    def query(self,a,b,k=0,l=0,r=-1):
        if r < 0: r = self.siz
        if r <= a or b <= l: return 0
        if a <= l and r <= b: return self.node[k]
        vl = self.query(a,b,k*2+1,l,(l+r)//2)
        vr = self.query(a,b,k*2+2,(l+r)//2,r)
        return 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"))