import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = [set([a]) for a in LS2()]


def seg_func(x,y):
    return x | y

unit = set([])

class SegTree:  # モノイドに対して適用可能、Nが2冪でなくても良い
    def __init__(self,N,seg_func,unit):
        self.N = N
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)
    def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR)


seg = SegTree(N,seg_func,unit)
seg.build(S)

Q = I()
for i in range(Q):
    a,b,c = LS()
    if a == '1':
        b = int(b)-1
        seg.set_val(b,set([c]))
    else:
        b,c = int(b)-1,int(c)-1
        print(len(seg.fold(b,c+1))) import sys sys def I(): return int(sys.stdin.readline().rstrip()) I def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり LS def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし LS2 N = I() N I() I set([a]) for a in LS2() for a in LS2() a LS2() LS2 for a in LS2() set([a]) set [a] a S = [set([a]) for a in LS2()] S [set([a]) for a in LS2()] def seg_func(x,y):
    return x | y seg_func return x | y x | y x y x x y y unit = set([]) unit set([]) set [] class SegTree:  # モノイドに対して適用可能、Nが2冪でなくても良い
    def __init__(self,N,seg_func,unit):
        self.N = N
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)
    def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR) SegTree def __init__(self,N,seg_func,unit):
        self.N = N
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)
     __init__ self.N = N self.N self N N self.func = seg_func self.func self func seg_func self.unit = unit self.unit self unit unit self.tree = [self.unit]*(2*self.N) self.tree self tree [self.unit]*(2*self.N) [self.unit] self.unit self unit 2*self.N 2 self.N self N self self N N seg_func seg_func unit unit def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
     build for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
         i range(self.N) range self.N self N self.tree[i+self.N] = init_value[i] self.tree[i+self.N] self.tree self tree i+self.N i self.N self N init_value[i] init_value i for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
     i range(self.N-1,0,-1) range self.N-1 self.N self N 1 0 -1 self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1]) self.tree[i] self.tree self tree i self.func(self.tree[i << 1],self.tree[i << 1 | 1]) self.func self func self.tree[i << 1] self.tree self tree i << 1 i 1 self.tree[i << 1 | 1] self.tree self tree i << 1 | 1 i << 1 i 1 1 self self init_value init_value def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
     set_val i += self.N i self.N self N self.tree[i] = x self.tree[i] self.tree self tree i x while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
     i > 1 i 1 i >>= 1 i 1 self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1]) self.tree[i] self.tree self tree i self.func(self.tree[i << 1],self.tree[i << 1 | 1]) self.func self func self.tree[i << 1] self.tree self tree i << 1 i 1 self.tree[i << 1 | 1] self.tree self tree i << 1 | 1 i << 1 i 1 1 self self i i x x def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR) fold L += self.N L self.N self N R += self.N R self.N self N vL = self.unit vL self.unit self unit vR = self.unit vR self.unit self unit while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
         L < R L R if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
             L & 1 L 1 vL = self.func(vL,self.tree[L]) vL self.func(vL,self.tree[L]) self.func self func vL self.tree[L] self.tree self tree L L += 1 L 1 if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
             R & 1 R 1 R -= 1 R 1 vR = self.func(self.tree[R],vR) vR self.func(self.tree[R],vR) self.func self func self.tree[R] self.tree self tree R vR L >>= 1 L 1 R >>= 1 R 1 return self.func(vL,vR) self.func(vL,vR) self.func self func vL vR self self L L R R seg = SegTree(N,seg_func,unit) seg SegTree(N,seg_func,unit) SegTree N seg_func unit seg.build(S) seg.build seg build S Q = I() Q I() I for i in range(Q):
    a,b,c = LS()
    if a == '1':
        b = int(b)-1
        seg.set_val(b,set([c]))
    else:
        b,c = int(b)-1,int(c)-1
        print(len(seg.fold(b,c+1))) i range(Q) range Q a,b,c = LS() a LS() LS b c if a == '1':
        b = int(b)-1
        seg.set_val(b,set([c]))
    else:
        b,c = int(b)-1,int(c)-1
        print(len(seg.fold(b,c+1))) a == '1' a '1' b = int(b)-1 b int(b)-1 int(b) int b 1 seg.set_val(b,set([c])) seg.set_val seg set_val b set([c]) set [c] c b,c = int(b)-1,int(c)-1 b int(b)-1 int(b) int b 1 c int(c)-1 int(c) int c 1 print(len(seg.fold(b,c+1))) print len(seg.fold(b,c+1)) len seg.fold(b,c+1) seg.fold seg fold b c+1 c 1 def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I class SegTree:  # モノイドに対して適用可能、Nが2冪でなくても良い
    def __init__(self,N,seg_func,unit):
        self.N = N
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)
    def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR) class SegTree:  # モノイドに対して適用可能、Nが2冪でなくても良い
    def __init__(self,N,seg_func,unit):
        self.N = N
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)
    def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR) SegTree b,c = LS() LS() b Q = I() I() Q c = LS() LS() c a,b,c = LS() LS() a b = int(b)-1 int(b)-1 b def seg_func(x,y):
    return x | y def seg_func(x,y):
    return x | y seg_func seg = SegTree(N,seg_func,unit) SegTree(N,seg_func,unit) seg N = I() I() N b,c = int(b)-1,int(c)-1 int(b)-1 b c = int(b)-1,int(c)-1 int(c)-1 c def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり LS def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし LS2 S = [set([a]) for a in LS2()] [set([a]) for a in LS2()] S unit = set([]) set([]) unit
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = [set([a]) for a in LS2()]


def seg_func(x,y):
    return x | y

unit = set([])

class SegTree:  # モノイドに対して適用可能、Nが2冪でなくても良い
    def __init__(self,N,seg_func,unit):
        self.N = N
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)
    def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR)


seg = SegTree(N,seg_func,unit)
seg.build(S)

Q = I()
for i in range(Q):
    a,b,c = LS()
    if a == '1':
        b = int(b)-1
        seg.set_val(b,set([c]))
    else:
        b,c = int(b)-1,int(c)-1
        print(len(seg.fold(b,c+1)))
