import sys
input = sys.stdin.readline

class SegmentTree:
    def __init__(self,l):
        nb = bin(len(l))[2:]
        b = sum([int(d) for d in nb])
        if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
        self.tree = [set() for _ in range(self.end_leaves*2)]
        
        for i in range(len(l)):
            self.tree[self.end_leaves+i].add(l[i])
            
    def union(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = self.tree[a*2] | self.tree[a*2+1]
            return self.tree[a]
        else:
            self.tree[a] = self.union(a*2) | self.union(a*2+1)
            return self.tree[a]
    def update(self,a,s):
        x = a + self.end_leaves
        if s not in self.tree[x]:
            self.tree[x] = set(s)
            while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
    def query(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = set()
        tr = set()
        while y - x > 1:
            if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
            if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            print(len(tl|tr|self.tree[x]))
        else:
            print(len(tl|tr|self.tree[x]|self.tree[y]))
            
            

N = int(input())
S = list(input())
st = SegmentTree(S)
st.union(1)
Q = int(input())
for i in range(Q):
    q = input().split()
    if q[0] == '1':
        st.update(int(q[1])-1,q[2])
    else:
        st.query(int(q[1])-1,int(q[2])-1) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class SegmentTree:
    def __init__(self,l):
        nb = bin(len(l))[2:]
        b = sum([int(d) for d in nb])
        if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
        self.tree = [set() for _ in range(self.end_leaves*2)]
        
        for i in range(len(l)):
            self.tree[self.end_leaves+i].add(l[i])
            
    def union(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = self.tree[a*2] | self.tree[a*2+1]
            return self.tree[a]
        else:
            self.tree[a] = self.union(a*2) | self.union(a*2+1)
            return self.tree[a]
    def update(self,a,s):
        x = a + self.end_leaves
        if s not in self.tree[x]:
            self.tree[x] = set(s)
            while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
    def query(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = set()
        tr = set()
        while y - x > 1:
            if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
            if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            print(len(tl|tr|self.tree[x]))
        else:
            print(len(tl|tr|self.tree[x]|self.tree[y]))
            
             SegmentTree def __init__(self,l):
        nb = bin(len(l))[2:]
        b = sum([int(d) for d in nb])
        if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
        self.tree = [set() for _ in range(self.end_leaves*2)]
        
        for i in range(len(l)):
            self.tree[self.end_leaves+i].add(l[i])
            
     __init__ nb = bin(len(l))[2:] nb bin(len(l))[2:] (len(l)) bin len(l) len l 2: 2 int(d) for d in nb for d in nb d nb for d in nb int(d) int d b = sum([int(d) for d in nb]) b sum([int(d) for d in nb]) sum [int(d) for d in nb] if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
         b == 1 b 1 self.end_leaves = pow(2,len(nb)-1) self.end_leaves self end_leaves pow(2,len(nb)-1) pow 2 len(nb)-1 len(nb) len nb 1 self.end_leaves = pow(2,len(nb)) self.end_leaves self end_leaves pow(2,len(nb)) pow 2 len(nb) len nb set() for _ in range(self.end_leaves*2) for _ in range(self.end_leaves*2) _ range(self.end_leaves*2) range self.end_leaves*2 self.end_leaves self end_leaves 2 for _ in range(self.end_leaves*2) set() set self.tree = [set() for _ in range(self.end_leaves*2)] self.tree self tree [set() for _ in range(self.end_leaves*2)] for i in range(len(l)):
            self.tree[self.end_leaves+i].add(l[i])
            
     i range(len(l)) range len(l) len l self.tree[self.end_leaves+i].add(l[i]) self.tree[self.end_leaves+i].add self.tree[self.end_leaves+i] self.tree self tree self.end_leaves+i self.end_leaves self end_leaves i add l[i] l i self self l l def union(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = self.tree[a*2] | self.tree[a*2+1]
            return self.tree[a]
        else:
            self.tree[a] = self.union(a*2) | self.union(a*2+1)
            return self.tree[a]
     union if a >= self.end_leaves // 2:
            self.tree[a] = self.tree[a*2] | self.tree[a*2+1]
            return self.tree[a]
        else:
            self.tree[a] = self.union(a*2) | self.union(a*2+1)
            return self.tree[a]
     a >= self.end_leaves // 2 a self.end_leaves // 2 self.end_leaves self end_leaves 2 self.tree[a] = self.tree[a*2] | self.tree[a*2+1] self.tree[a] self.tree self tree a self.tree[a*2] | self.tree[a*2+1] self.tree[a*2] self.tree self tree a*2 a 2 self.tree[a*2+1] self.tree self tree a*2+1 a*2 a 2 1 return self.tree[a] self.tree[a] self.tree self tree a self.tree[a] = self.union(a*2) | self.union(a*2+1) self.tree[a] self.tree self tree a self.union(a*2) | self.union(a*2+1) self.union(a*2) self.union self union a*2 a 2 self.union(a*2+1) self.union self union a*2+1 a*2 a 2 1 return self.tree[a] self.tree[a] self.tree self tree a self self a a def update(self,a,s):
        x = a + self.end_leaves
        if s not in self.tree[x]:
            self.tree[x] = set(s)
            while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
     update x = a + self.end_leaves x a + self.end_leaves a self.end_leaves self end_leaves if s not in self.tree[x]:
            self.tree[x] = set(s)
            while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
     s not in self.tree[x] s self.tree[x] self.tree self tree x self.tree[x] = set(s) self.tree[x] self.tree self tree x set(s) set s while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
     x > 1 x 1 x //= 2 x 2 self.tree[x] = self.tree[x*2] | self.tree[x*2+1] self.tree[x] self.tree self tree x self.tree[x*2] | self.tree[x*2+1] self.tree[x*2] self.tree self tree x*2 x 2 self.tree[x*2+1] self.tree self tree x*2+1 x*2 x 2 1 self self a a s s def query(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = set()
        tr = set()
        while y - x > 1:
            if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
            if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            print(len(tl|tr|self.tree[x]))
        else:
            print(len(tl|tr|self.tree[x]|self.tree[y]))
            
             query x = l + self.end_leaves x l + self.end_leaves l self.end_leaves self end_leaves y = r + self.end_leaves y r + self.end_leaves r self.end_leaves self end_leaves tl = set() tl set() set tr = set() tr set() set while y - x > 1:
            if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
            if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
            x >>= 1
            y >>= 1
         y - x > 1 y - x y x 1 if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
             x % 2 == 1 x % 2 x 2 1 tl = tl | self.tree[x] tl tl | self.tree[x] tl self.tree[x] self.tree self tree x x += 1 x 1 if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
             y % 2 == 0 y % 2 y 2 0 tr = self.tree[y] | tr tr self.tree[y] | tr self.tree[y] self.tree self tree y tr y -= 1 y 1 x >>= 1 x 1 y >>= 1 y 1 if y - x == 0:
            print(len(tl|tr|self.tree[x]))
        else:
            print(len(tl|tr|self.tree[x]|self.tree[y]))
            
             y - x == 0 y - x y x 0 print(len(tl|tr|self.tree[x])) print len(tl|tr|self.tree[x]) len tl|tr|self.tree[x] tl|tr tl tr self.tree[x] self.tree self tree x print(len(tl|tr|self.tree[x]|self.tree[y])) print len(tl|tr|self.tree[x]|self.tree[y]) len tl|tr|self.tree[x]|self.tree[y] tl|tr|self.tree[x] tl|tr tl tr self.tree[x] self.tree self tree x self.tree[y] self.tree self tree y self self l l r r N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input st = SegmentTree(S) st SegmentTree(S) SegmentTree S st.union(1) st.union st union 1 Q = int(input()) Q int(input()) int input() input for i in range(Q):
    q = input().split()
    if q[0] == '1':
        st.update(int(q[1])-1,q[2])
    else:
        st.query(int(q[1])-1,int(q[2])-1) i range(Q) range Q q = input().split() q input().split() ().split () input split if q[0] == '1':
        st.update(int(q[1])-1,q[2])
    else:
        st.query(int(q[1])-1,int(q[2])-1) q[0] == '1' q[0] q 0 '1' st.update(int(q[1])-1,q[2]) st.update st update int(q[1])-1 int(q[1]) int q[1] q 1 1 q[2] q 2 st.query(int(q[1])-1,int(q[2])-1) st.query st query int(q[1])-1 int(q[1]) int q[1] q 1 1 int(q[2])-1 int(q[2]) int q[2] q 2 1 st = SegmentTree(S) SegmentTree(S) st q = input().split() input().split() q class SegmentTree:
    def __init__(self,l):
        nb = bin(len(l))[2:]
        b = sum([int(d) for d in nb])
        if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
        self.tree = [set() for _ in range(self.end_leaves*2)]
        
        for i in range(len(l)):
            self.tree[self.end_leaves+i].add(l[i])
            
    def union(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = self.tree[a*2] | self.tree[a*2+1]
            return self.tree[a]
        else:
            self.tree[a] = self.union(a*2) | self.union(a*2+1)
            return self.tree[a]
    def update(self,a,s):
        x = a + self.end_leaves
        if s not in self.tree[x]:
            self.tree[x] = set(s)
            while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
    def query(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = set()
        tr = set()
        while y - x > 1:
            if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
            if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            print(len(tl|tr|self.tree[x]))
        else:
            print(len(tl|tr|self.tree[x]|self.tree[y]))
            
             class SegmentTree:
    def __init__(self,l):
        nb = bin(len(l))[2:]
        b = sum([int(d) for d in nb])
        if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
        self.tree = [set() for _ in range(self.end_leaves*2)]
        
        for i in range(len(l)):
            self.tree[self.end_leaves+i].add(l[i])
            
    def union(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = self.tree[a*2] | self.tree[a*2+1]
            return self.tree[a]
        else:
            self.tree[a] = self.union(a*2) | self.union(a*2+1)
            return self.tree[a]
    def update(self,a,s):
        x = a + self.end_leaves
        if s not in self.tree[x]:
            self.tree[x] = set(s)
            while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
    def query(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = set()
        tr = set()
        while y - x > 1:
            if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
            if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            print(len(tl|tr|self.tree[x]))
        else:
            print(len(tl|tr|self.tree[x]|self.tree[y]))
            
             SegmentTree N = int(input()) int(input()) N S = list(input()) list(input()) S input = sys.stdin.readline sys.stdin.readline input Q = int(input()) int(input()) Q
import sys
input = sys.stdin.readline

class SegmentTree:
    def __init__(self,l):
        nb = bin(len(l))[2:]
        b = sum([int(d) for d in nb])
        if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
        self.tree = [set() for _ in range(self.end_leaves*2)]
        
        for i in range(len(l)):
            self.tree[self.end_leaves+i].add(l[i])
            
    def union(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = self.tree[a*2] | self.tree[a*2+1]
            return self.tree[a]
        else:
            self.tree[a] = self.union(a*2) | self.union(a*2+1)
            return self.tree[a]
    def update(self,a,s):
        x = a + self.end_leaves
        if s not in self.tree[x]:
            self.tree[x] = set(s)
            while x > 1:
                x //= 2
                self.tree[x] = self.tree[x*2] | self.tree[x*2+1]
    def query(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = set()
        tr = set()
        while y - x > 1:
            if x % 2 == 1:
                tl = tl | self.tree[x]
                x += 1
            if y % 2 == 0:
                tr = self.tree[y] | tr
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            print(len(tl|tr|self.tree[x]))
        else:
            print(len(tl|tr|self.tree[x]|self.tree[y]))
            
            

N = int(input())
S = list(input())
st = SegmentTree(S)
st.union(1)
Q = int(input())
for i in range(Q):
    q = input().split()
    if q[0] == '1':
        st.update(int(q[1])-1,q[2])
    else:
        st.query(int(q[1])-1,int(q[2])-1)