import sys
input = sys.stdin.readline

class SegmentTree():
    def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

    def subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

    def query(self, l, r):
        return len(self.subquery(l, r, 0, 0, 2**self.size))

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2]

n = int(input())
S = [ord(c) for c in list(input())]
segtree = SegmentTree(S, 19)
for _ in range(int(input())):
    t, i, c = input().split()
    if t == '1':
        segtree.update(int(i)-1, ord(c))
    if t == '2':
        print(segtree.query(int(i)-1, int(c))) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class SegmentTree():
    def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

    def subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

    def query(self, l, r):
        return len(self.subquery(l, r, 0, 0, 2**self.size))

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2] SegmentTree def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

     __init__ self.size = n self.size self size n self.array = [set()] * (2**(self.size + 1) - 1) self.array self array [set()] * (2**(self.size + 1) - 1) [set()] set() set 2**(self.size + 1) - 1 2**(self.size + 1) 2 self.size + 1 self.size self size 1 1 for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
         i c enumerate(S) enumerate S self.array[i + 2**self.size - 1] = {c} self.array[i + 2**self.size - 1] self.array self array i + 2**self.size - 1 i + 2**self.size i 2**self.size 2 self.size self size 1 {c} for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

     i range(2**self.size - 1)[::-1] (2**self.size - 1) range 2**self.size - 1 2**self.size 2 self.size self size 1 ::-1 -1 self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2] self.array[i] self.array self array i self.array[2 * i + 1] | self.array[2 * i + 2] self.array[2 * i + 1] self.array self array 2 * i + 1 2 * i 2 i 1 self.array[2 * i + 2] self.array self array 2 * i + 2 2 * i 2 i 2 self self S S n n def subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

     subquery if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

     j <= l or r <= i j <= l j l r <= i r i return set() set() set elif l <= i and j <= r:
            return self.array[k]
         l <= i and j <= r l <= i l i j <= r j r return self.array[k] self.array[k] self.array self array k l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2) l_set self.subquery(l, r, 2 * k + 1, i, (i + j) // 2) self.subquery self subquery l r 2 * k + 1 2 * k 2 k 1 i (i + j) // 2 i + j i j 2 r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j) r_set self.subquery(l, r, 2 * k + 2, (i + j) // 2, j) self.subquery self subquery l r 2 * k + 2 2 * k 2 k 2 (i + j) // 2 i + j i j 2 j return l_set | r_set l_set | r_set l_set r_set self self l l r r k k i i j j def query(self, l, r):
        return len(self.subquery(l, r, 0, 0, 2**self.size))

     query return len(self.subquery(l, r, 0, 0, 2**self.size)) len(self.subquery(l, r, 0, 0, 2**self.size)) len self.subquery(l, r, 0, 0, 2**self.size) self.subquery self subquery l r 0 0 2**self.size 2 self.size self size self self l l r r def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2] update tmp = i + 2**self.size - 1 tmp i + 2**self.size - 1 i + 2**self.size i 2**self.size 2 self.size self size 1 self.array[tmp] = {c} self.array[tmp] self.array self array tmp {c} while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2] tmp > 0 tmp 0 tmp = (tmp - 1) // 2 tmp (tmp - 1) // 2 tmp - 1 tmp 1 2 self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2] self.array[tmp] self.array self array tmp self.array[2 * tmp + 1] | self.array[2 * tmp + 2] self.array[2 * tmp + 1] self.array self array 2 * tmp + 1 2 * tmp 2 tmp 1 self.array[2 * tmp + 2] self.array self array 2 * tmp + 2 2 * tmp 2 tmp 2 self self i i c c n = int(input()) n int(input()) int input() input ord(c) for c in list(input()) for c in list(input()) c list(input()) list input() input for c in list(input()) ord(c) ord c S = [ord(c) for c in list(input())] S [ord(c) for c in list(input())] segtree = SegmentTree(S, 19) segtree SegmentTree(S, 19) SegmentTree S 19 for _ in range(int(input())):
    t, i, c = input().split()
    if t == '1':
        segtree.update(int(i)-1, ord(c))
    if t == '2':
        print(segtree.query(int(i)-1, int(c))) _ range(int(input())) range int(input()) int input() input t, i, c = input().split() t input().split() ().split () input split i c if t == '1':
        segtree.update(int(i)-1, ord(c))
     t == '1' t '1' segtree.update(int(i)-1, ord(c)) segtree.update segtree update int(i)-1 int(i) int i 1 ord(c) ord c if t == '2':
        print(segtree.query(int(i)-1, int(c))) t == '2' t '2' print(segtree.query(int(i)-1, int(c))) print segtree.query(int(i)-1, int(c)) segtree.query segtree query int(i)-1 int(i) int i 1 int(c) int c c = input().split() input().split() c segtree = SegmentTree(S, 19) SegmentTree(S, 19) segtree n = int(input()) int(input()) n class SegmentTree():
    def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

    def subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

    def query(self, l, r):
        return len(self.subquery(l, r, 0, 0, 2**self.size))

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2] class SegmentTree():
    def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

    def subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

    def query(self, l, r):
        return len(self.subquery(l, r, 0, 0, 2**self.size))

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2] SegmentTree i, c = input().split() input().split() i S = [ord(c) for c in list(input())] [ord(c) for c in list(input())] S input = sys.stdin.readline sys.stdin.readline input t, i, c = input().split() input().split() t
import sys
input = sys.stdin.readline

class SegmentTree():
    def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

    def subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

    def query(self, l, r):
        return len(self.subquery(l, r, 0, 0, 2**self.size))

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2]

n = int(input())
S = [ord(c) for c in list(input())]
segtree = SegmentTree(S, 19)
for _ in range(int(input())):
    t, i, c = input().split()
    if t == '1':
        segtree.update(int(i)-1, ord(c))
    if t == '2':
        print(segtree.query(int(i)-1, int(c)))
