class SegmentTree():
    def __init__(self, size):
        self.size = 2**((size-1).bit_length())
        self.val = [0]*(self.size*2)
    
    def update(self, i, x):
        i += self.size
        self.val[i] = x
        
        while i > 0:
            i = i >> 1
            self.val[i] = self.val[2*i] + self.val[2*i+1]
    
    def query(self, l, r):
        l += self.size
        r += self.size

        l_sum = 0
        r_sum = 0

        while l < r:
            if l & 1:
                l_sum += self.val[l]
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum += self.val[r]
            r = r >> 1

        return l_sum + r_sum

def convertAlphabetToNumber(s):
    return ord(s) - ord('a')

N = int(input())
S = input()
Q = int(input())
query = [input().split() for i in range(Q)]

for i in range(Q):
    query[i][0] = int(query[i][0])
    query[i][1] = int(query[i][1]) - 1
    if query[i][0] == 2:
        query[i][2] = int(query[i][2]) - 1

alphabet_position = [SegmentTree(N) for i in range(28)]

for i in range(N):
    num = convertAlphabetToNumber(S[i])
    alphabet_position[num].update(i, 1)

for i in range(Q):
    if query[i][0] == 1:
        for j in range(28):
            if j == convertAlphabetToNumber(query[i][2]):
                alphabet_position[j].update(query[i][1], 1)
            else:
                alphabet_position[j].update(query[i][1], 0)
    else:
        cnt = 0
        for j in range(28):
            if alphabet_position[j].query(query[i][1], query[i][2] + 1) > 0:
                cnt += 1
        print(cnt) class SegmentTree():
    def __init__(self, size):
        self.size = 2**((size-1).bit_length())
        self.val = [0]*(self.size*2)
    
    def update(self, i, x):
        i += self.size
        self.val[i] = x
        
        while i > 0:
            i = i >> 1
            self.val[i] = self.val[2*i] + self.val[2*i+1]
    
    def query(self, l, r):
        l += self.size
        r += self.size

        l_sum = 0
        r_sum = 0

        while l < r:
            if l & 1:
                l_sum += self.val[l]
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum += self.val[r]
            r = r >> 1

        return l_sum + r_sum SegmentTree def __init__(self, size):
        self.size = 2**((size-1).bit_length())
        self.val = [0]*(self.size*2)
    
     __init__ self.size = 2**((size-1).bit_length()) self.size self size 2**((size-1).bit_length()) 2 (size-1).bit_length() size-1).bit_length size-1 size 1 bit_length self.val = [0]*(self.size*2) self.val self val [0]*(self.size*2) [0] 0 self.size*2 self.size self size 2 self self size size def update(self, i, x):
        i += self.size
        self.val[i] = x
        
        while i > 0:
            i = i >> 1
            self.val[i] = self.val[2*i] + self.val[2*i+1]
    
     update i += self.size i self.size self size self.val[i] = x self.val[i] self.val self val i x while i > 0:
            i = i >> 1
            self.val[i] = self.val[2*i] + self.val[2*i+1]
    
     i > 0 i 0 i = i >> 1 i i >> 1 i 1 self.val[i] = self.val[2*i] + self.val[2*i+1] self.val[i] self.val self val i self.val[2*i] + self.val[2*i+1] self.val[2*i] self.val self val 2*i 2 i self.val[2*i+1] self.val self val 2*i+1 2*i 2 i 1 self self i i x x def query(self, l, r):
        l += self.size
        r += self.size

        l_sum = 0
        r_sum = 0

        while l < r:
            if l & 1:
                l_sum += self.val[l]
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum += self.val[r]
            r = r >> 1

        return l_sum + r_sum query l += self.size l self.size self size r += self.size r self.size self size l_sum = 0 l_sum 0 r_sum = 0 r_sum 0 while l < r:
            if l & 1:
                l_sum += self.val[l]
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum += self.val[r]
            r = r >> 1

         l < r l r if l & 1:
                l_sum += self.val[l]
                l += 1
             l & 1 l 1 l_sum += self.val[l] l_sum self.val[l] self.val self val l l += 1 l 1 l = l >> 1 l l >> 1 l 1 if r & 1:
                r -= 1
                r_sum += self.val[r]
             r & 1 r 1 r -= 1 r 1 r_sum += self.val[r] r_sum self.val[r] self.val self val r r = r >> 1 r r >> 1 r 1 return l_sum + r_sum l_sum + r_sum l_sum r_sum self self l l r r def convertAlphabetToNumber(s):
    return ord(s) - ord('a') convertAlphabetToNumber return ord(s) - ord('a') ord(s) - ord('a') ord(s) ord s ord('a') ord 'a' s s N = int(input()) N int(input()) int input() input S = input() S input() input Q = int(input()) Q int(input()) int input() input input().split() for i in range(Q) for i in range(Q) i range(Q) range Q for i in range(Q) input().split() ().split () input split query = [input().split() for i in range(Q)] query [input().split() for i in range(Q)] for i in range(Q):
    query[i][0] = int(query[i][0])
    query[i][1] = int(query[i][1]) - 1
    if query[i][0] == 2:
        query[i][2] = int(query[i][2]) - 1 i range(Q) range Q query[i][0] = int(query[i][0]) query[i][0] [i] query i 0 int(query[i][0]) int query[i][0] [i] query i 0 query[i][1] = int(query[i][1]) - 1 query[i][1] [i] query i 1 int(query[i][1]) - 1 int(query[i][1]) int query[i][1] [i] query i 1 1 if query[i][0] == 2:
        query[i][2] = int(query[i][2]) - 1 query[i][0] == 2 query[i][0] [i] query i 0 2 query[i][2] = int(query[i][2]) - 1 query[i][2] [i] query i 2 int(query[i][2]) - 1 int(query[i][2]) int query[i][2] [i] query i 2 1 SegmentTree(N) for i in range(28) for i in range(28) i range(28) range 28 for i in range(28) SegmentTree(N) SegmentTree N alphabet_position = [SegmentTree(N) for i in range(28)] alphabet_position [SegmentTree(N) for i in range(28)] for i in range(N):
    num = convertAlphabetToNumber(S[i])
    alphabet_position[num].update(i, 1) i range(N) range N num = convertAlphabetToNumber(S[i]) num convertAlphabetToNumber(S[i]) convertAlphabetToNumber S[i] S i alphabet_position[num].update(i, 1) [num].update [num] alphabet_position num update i 1 for i in range(Q):
    if query[i][0] == 1:
        for j in range(28):
            if j == convertAlphabetToNumber(query[i][2]):
                alphabet_position[j].update(query[i][1], 1)
            else:
                alphabet_position[j].update(query[i][1], 0)
    else:
        cnt = 0
        for j in range(28):
            if alphabet_position[j].query(query[i][1], query[i][2] + 1) > 0:
                cnt += 1
        print(cnt) i range(Q) range Q if query[i][0] == 1:
        for j in range(28):
            if j == convertAlphabetToNumber(query[i][2]):
                alphabet_position[j].update(query[i][1], 1)
            else:
                alphabet_position[j].update(query[i][1], 0)
    else:
        cnt = 0
        for j in range(28):
            if alphabet_position[j].query(query[i][1], query[i][2] + 1) > 0:
                cnt += 1
        print(cnt) query[i][0] == 1 query[i][0] [i] query i 0 1 for j in range(28):
            if j == convertAlphabetToNumber(query[i][2]):
                alphabet_position[j].update(query[i][1], 1)
            else:
                alphabet_position[j].update(query[i][1], 0)
     j range(28) range 28 if j == convertAlphabetToNumber(query[i][2]):
                alphabet_position[j].update(query[i][1], 1)
            else:
                alphabet_position[j].update(query[i][1], 0)
     j == convertAlphabetToNumber(query[i][2]) j convertAlphabetToNumber(query[i][2]) convertAlphabetToNumber query[i][2] [i] query i 2 alphabet_position[j].update(query[i][1], 1) [j].update [j] alphabet_position j update query[i][1] [i] query i 1 1 alphabet_position[j].update(query[i][1], 0) [j].update [j] alphabet_position j update query[i][1] [i] query i 1 0 cnt = 0 cnt 0 for j in range(28):
            if alphabet_position[j].query(query[i][1], query[i][2] + 1) > 0:
                cnt += 1
         j range(28) range 28 if alphabet_position[j].query(query[i][1], query[i][2] + 1) > 0:
                cnt += 1
         alphabet_position[j].query(query[i][1], query[i][2] + 1) > 0 alphabet_position[j].query(query[i][1], query[i][2] + 1) [j].query [j] alphabet_position j query query[i][1] [i] query i 1 query[i][2] + 1 query[i][2] [i] query i 2 1 0 cnt += 1 cnt 1 print(cnt) print cnt class SegmentTree():
    def __init__(self, size):
        self.size = 2**((size-1).bit_length())
        self.val = [0]*(self.size*2)
    
    def update(self, i, x):
        i += self.size
        self.val[i] = x
        
        while i > 0:
            i = i >> 1
            self.val[i] = self.val[2*i] + self.val[2*i+1]
    
    def query(self, l, r):
        l += self.size
        r += self.size

        l_sum = 0
        r_sum = 0

        while l < r:
            if l & 1:
                l_sum += self.val[l]
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum += self.val[r]
            r = r >> 1

        return l_sum + r_sum class SegmentTree():
    def __init__(self, size):
        self.size = 2**((size-1).bit_length())
        self.val = [0]*(self.size*2)
    
    def update(self, i, x):
        i += self.size
        self.val[i] = x
        
        while i > 0:
            i = i >> 1
            self.val[i] = self.val[2*i] + self.val[2*i+1]
    
    def query(self, l, r):
        l += self.size
        r += self.size

        l_sum = 0
        r_sum = 0

        while l < r:
            if l & 1:
                l_sum += self.val[l]
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum += self.val[r]
            r = r >> 1

        return l_sum + r_sum SegmentTree def convertAlphabetToNumber(s):
    return ord(s) - ord('a') def convertAlphabetToNumber(s):
    return ord(s) - ord('a') convertAlphabetToNumber query = [input().split() for i in range(Q)] [input().split() for i in range(Q)] query alphabet_position = [SegmentTree(N) for i in range(28)] [SegmentTree(N) for i in range(28)] alphabet_position Q = int(input()) int(input()) Q num = convertAlphabetToNumber(S[i]) convertAlphabetToNumber(S[i]) num cnt += 1 1 cnt N = int(input()) int(input()) N S = input() input() S cnt = 0 0 cnt
class SegmentTree():
    def __init__(self, size):
        self.size = 2**((size-1).bit_length())
        self.val = [0]*(self.size*2)
    
    def update(self, i, x):
        i += self.size
        self.val[i] = x
        
        while i > 0:
            i = i >> 1
            self.val[i] = self.val[2*i] + self.val[2*i+1]
    
    def query(self, l, r):
        l += self.size
        r += self.size

        l_sum = 0
        r_sum = 0

        while l < r:
            if l & 1:
                l_sum += self.val[l]
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum += self.val[r]
            r = r >> 1

        return l_sum + r_sum

def convertAlphabetToNumber(s):
    return ord(s) - ord('a')

N = int(input())
S = input()
Q = int(input())
query = [input().split() for i in range(Q)]

for i in range(Q):
    query[i][0] = int(query[i][0])
    query[i][1] = int(query[i][1]) - 1
    if query[i][0] == 2:
        query[i][2] = int(query[i][2]) - 1

alphabet_position = [SegmentTree(N) for i in range(28)]

for i in range(N):
    num = convertAlphabetToNumber(S[i])
    alphabet_position[num].update(i, 1)

for i in range(Q):
    if query[i][0] == 1:
        for j in range(28):
            if j == convertAlphabetToNumber(query[i][2]):
                alphabet_position[j].update(query[i][1], 1)
            else:
                alphabet_position[j].update(query[i][1], 0)
    else:
        cnt = 0
        for j in range(28):
            if alphabet_position[j].query(query[i][1], query[i][2] + 1) > 0:
                cnt += 1
        print(cnt)