class SegT():
    def __init__(self, size, origin):
        self.size = 1
        while self.size < size: self.size *= 2
        self.data = [set() for _ in range(self.size * 2 - 1)]
        for i in range(size):
            self.data[i+self.size-1] = origin[i]
        for i in range(self.size-2,-1,-1):
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    
    def update(self, i, x):
        i += (self.size - 1)
        self.data[i] = {x}
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]
        
    def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return set()
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return vl | vr

N = int(input())
S = input()
Q = int(input())
origin = [{i} for i in S]

segt = SegT(N, origin)

for i in range(Q):
    t, l, r = input().split()
    if t == "1":
        segt.update(int(l)-1, r)
    else:
        x = segt.get(int(l)-1,int(r))
        print(len(x)) class SegT():
    def __init__(self, size, origin):
        self.size = 1
        while self.size < size: self.size *= 2
        self.data = [set() for _ in range(self.size * 2 - 1)]
        for i in range(size):
            self.data[i+self.size-1] = origin[i]
        for i in range(self.size-2,-1,-1):
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    
    def update(self, i, x):
        i += (self.size - 1)
        self.data[i] = {x}
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]
        
    def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return set()
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return vl | vr SegT def __init__(self, size, origin):
        self.size = 1
        while self.size < size: self.size *= 2
        self.data = [set() for _ in range(self.size * 2 - 1)]
        for i in range(size):
            self.data[i+self.size-1] = origin[i]
        for i in range(self.size-2,-1,-1):
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    
     __init__ self.size = 1 self.size self size 1 while self.size < size: self.size *= 2
         self.size < size self.size self size size set() for _ in range(self.size * 2 - 1) for _ in range(self.size * 2 - 1) _ range(self.size * 2 - 1) range self.size * 2 - 1 self.size * 2 self.size self size 2 1 for _ in range(self.size * 2 - 1) set() set self.data = [set() for _ in range(self.size * 2 - 1)] self.data self data [set() for _ in range(self.size * 2 - 1)] for i in range(size):
            self.data[i+self.size-1] = origin[i]
         i range(size) range size self.data[i+self.size-1] = origin[i] self.data[i+self.size-1] self.data self data i+self.size-1 i+self.size i self.size self size 1 origin[i] origin i for i in range(self.size-2,-1,-1):
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    
     i range(self.size-2,-1,-1) range self.size-2 self.size self size 2 -1 -1 self.data[i] = self.data[i*2+1] | self.data[i*2+2] self.data[i] self.data self data i self.data[i*2+1] | self.data[i*2+2] self.data[i*2+1] self.data self data i*2+1 i*2 i 2 1 self.data[i*2+2] self.data self data i*2+2 i*2 i 2 2 self self size size origin origin def update(self, i, x):
        i += (self.size - 1)
        self.data[i] = {x}
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]
        
     update i += (self.size - 1) i self.size - 1 self.size self size 1 self.data[i] = {x} self.data[i] self.data self data i {x} while i > 0:
            i = (i - 1) // 2
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]
        
     i > 0 i 0 i = (i - 1) // 2 i (i - 1) // 2 i - 1 i 1 2 self.data[i] = self.data[i*2+1] | self.data[i*2+2] self.data[i] self.data self data i self.data[i*2+1] | self.data[i*2+2] self.data[i*2+1] self.data self data i*2+1 i*2 i 2 1 self.data[i*2+2] self.data self data i*2+2 i*2 i 2 2 self self i i x x def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return set()
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return vl | vr get if r < 0: r = self.size
         r < 0 r 0 if r <= a or b <= l: return set()
         r <= a or b <= l r <= a r a b <= l b l if a <= l and r <= b: return self.data[node]
         a <= l and r <= b a <= l a l r <= b r b vl = self.get(a, b, node*2+1, l, (l+r)//2) vl self.get(a, b, node*2+1, l, (l+r)//2) self.get self get a b node*2+1 node*2 node 2 1 l (l+r)//2 l+r l r 2 vr = self.get(a, b, node*2+2, (l+r)//2, r) vr self.get(a, b, node*2+2, (l+r)//2, r) self.get self get a b node*2+2 node*2 node 2 2 (l+r)//2 l+r l r 2 r return vl | vr vl | vr vl vr self self a a b b node=0 node 0 l=0 l 0 r=-1 r -1 N = int(input()) N int(input()) int input() input S = input() S input() input Q = int(input()) Q int(input()) int input() input {i} for i in S for i in S i S for i in S {i} origin = [{i} for i in S] origin [{i} for i in S] segt = SegT(N, origin) segt SegT(N, origin) SegT N origin for i in range(Q):
    t, l, r = input().split()
    if t == "1":
        segt.update(int(l)-1, r)
    else:
        x = segt.get(int(l)-1,int(r))
        print(len(x)) i range(Q) range Q t, l, r = input().split() t input().split() ().split () input split l r if t == "1":
        segt.update(int(l)-1, r)
    else:
        x = segt.get(int(l)-1,int(r))
        print(len(x)) t == "1" t "1" segt.update(int(l)-1, r) segt.update segt update int(l)-1 int(l) int l 1 r x = segt.get(int(l)-1,int(r)) x segt.get(int(l)-1,int(r)) segt.get segt get int(l)-1 int(l) int l 1 int(r) int r print(len(x)) print len(x) len x origin = [{i} for i in S] [{i} for i in S] origin Q = int(input()) int(input()) Q x = segt.get(int(l)-1,int(r)) segt.get(int(l)-1,int(r)) x t, l, r = input().split() input().split() t S = input() input() S segt = SegT(N, origin) SegT(N, origin) segt class SegT():
    def __init__(self, size, origin):
        self.size = 1
        while self.size < size: self.size *= 2
        self.data = [set() for _ in range(self.size * 2 - 1)]
        for i in range(size):
            self.data[i+self.size-1] = origin[i]
        for i in range(self.size-2,-1,-1):
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    
    def update(self, i, x):
        i += (self.size - 1)
        self.data[i] = {x}
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]
        
    def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return set()
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return vl | vr class SegT():
    def __init__(self, size, origin):
        self.size = 1
        while self.size < size: self.size *= 2
        self.data = [set() for _ in range(self.size * 2 - 1)]
        for i in range(size):
            self.data[i+self.size-1] = origin[i]
        for i in range(self.size-2,-1,-1):
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    
    def update(self, i, x):
        i += (self.size - 1)
        self.data[i] = {x}
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]
        
    def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return set()
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return vl | vr SegT N = int(input()) int(input()) N r = input().split() input().split() r l, r = input().split() input().split() l
class SegT():
    def __init__(self, size, origin):
        self.size = 1
        while self.size < size: self.size *= 2
        self.data = [set() for _ in range(self.size * 2 - 1)]
        for i in range(size):
            self.data[i+self.size-1] = origin[i]
        for i in range(self.size-2,-1,-1):
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]

    
    def update(self, i, x):
        i += (self.size - 1)
        self.data[i] = {x}
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self.data[i*2+1] | self.data[i*2+2]
        
    def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return set()
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return vl | vr

N = int(input())
S = input()
Q = int(input())
origin = [{i} for i in S]

segt = SegT(N, origin)

for i in range(Q):
    t, l, r = input().split()
    if t == "1":
        segt.update(int(l)-1, r)
    else:
        x = segt.get(int(l)-1,int(r))
        print(len(x))
