import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# SegTreeの関数
def segfunc(x, y):
    return x | y
# 単位元
# min->inf, max->-inf, add->0, mul->1
ide_ele = set()

# セグメント木
class SegTree:
    """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
        return res


def main():
    N = NI()
    S = SI()
    Q = NI()
    querys = [list(SI().split()) for _ in range(Q)]
    S_sets = []
    for s in S:
        tmp = set()
        tmp.add(s)
        S_sets.append(tmp)

    segtree = SegTree(S_sets, segfunc, ide_ele)

    for query in querys:
        if query[0] == "1":
            segtree.update(int(query[1]) - 1, {query[2]})
        else:
            l, r = int(query[1])-1, int(query[2])
            print(len(segtree.query(l, r)))



if __name__ == "__main__":
    main() import sys sys import math math from collections import deque sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip NI = lambda: int(input()) NI lambda: int(input()) int(input()) int input() input NMI = lambda: map(int, input().split()) NMI lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split NLI = lambda: list(NMI()) NLI lambda: list(NMI()) list(NMI()) list NMI() NMI SI = lambda: input() SI lambda: input() input() input [int(num)] * w for _ in range(h) for _ in range(h) _ range(h) range h for _ in range(h) [int(num)] * w [int(num)] int(num) int num w def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# SegTreeの関数 make_grid h h w w num num def segfunc(x, y):
    return x | y
# 単位元
# min->inf, max->-inf, add->0, mul->1 segfunc return x | y x | y x y x x y y ide_ele = set() ide_ele set() set class SegTree:
    """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
        return res SegTree """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """ def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

     __init__ n = len(init_val) n len(init_val) len init_val self.segfunc = segfunc self.segfunc self segfunc segfunc self.ide_ele = ide_ele self.ide_ele self ide_ele ide_ele self.num = 1 << (n-1).bit_length() self.num self num 1 << (n-1).bit_length() 1 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length self.tree = [ide_ele] * 2 * self.num self.tree self tree [ide_ele] * 2 * self.num [ide_ele] * 2 [ide_ele] ide_ele 2 self.num self num for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
         i range(n) range n self.tree[self.num + i] = init_val[i] self.tree[self.num + i] self.tree self tree self.num + i self.num self num i init_val[i] init_val i for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

     i range(self.num - 1, 0, -1) range self.num - 1 self.num self num 1 0 -1 self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1]) self.tree[i] self.tree self tree i self.segfunc(self.tree[2*i], self.tree[2*i+1]) self.segfunc self segfunc self.tree[2*i] self.tree self tree 2*i 2 i self.tree[2*i+1] self.tree self tree 2*i+1 2*i 2 i 1 self self init_val init_val segfunc segfunc ide_ele ide_ele def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

     update """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """ k += self.num k self.num self num self.tree[k] = x self.tree[k] self.tree self tree k x while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

     k > 1 k 1 self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) self.tree[k>>1] self.tree self tree k>>1 k 1 self.segfunc(self.tree[k], self.tree[k ^ 1]) self.segfunc self segfunc self.tree[k] self.tree self tree k self.tree[k ^ 1] self.tree self tree k ^ 1 k 1 k >>= 1 k 1 self self k k x x def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
        return res query """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """ res = self.ide_ele res self.ide_ele self ide_ele l += self.num l self.num self num r += self.num r self.num self num while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
         l < r l r if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
             l & 1 l 1 res = self.segfunc(res, self.tree[l]) res self.segfunc(res, self.tree[l]) self.segfunc self segfunc res self.tree[l] self.tree self tree l l += 1 l 1 if r & 1:
                res = self.segfunc(res, self.tree[r-1])
             r & 1 r 1 res = self.segfunc(res, self.tree[r-1]) res self.segfunc(res, self.tree[r-1]) self.segfunc self segfunc res self.tree[r-1] self.tree self tree r-1 r 1 l >>= 1 l 1 r >>= 1 r 1 return res res self self l l r r def main():
    N = NI()
    S = SI()
    Q = NI()
    querys = [list(SI().split()) for _ in range(Q)]
    S_sets = []
    for s in S:
        tmp = set()
        tmp.add(s)
        S_sets.append(tmp)

    segtree = SegTree(S_sets, segfunc, ide_ele)

    for query in querys:
        if query[0] == "1":
            segtree.update(int(query[1]) - 1, {query[2]})
        else:
            l, r = int(query[1])-1, int(query[2])
            print(len(segtree.query(l, r))) main N = NI() N NI() NI S = SI() S SI() SI Q = NI() Q NI() NI list(SI().split()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) list(SI().split()) list SI().split() ().split () SI split querys = [list(SI().split()) for _ in range(Q)] querys [list(SI().split()) for _ in range(Q)] S_sets = [] S_sets [] for s in S:
        tmp = set()
        tmp.add(s)
        S_sets.append(tmp)

     s S tmp = set() tmp set() set tmp.add(s) tmp.add tmp add s S_sets.append(tmp) S_sets.append S_sets append tmp segtree = SegTree(S_sets, segfunc, ide_ele) segtree SegTree(S_sets, segfunc, ide_ele) SegTree S_sets segfunc ide_ele for query in querys:
        if query[0] == "1":
            segtree.update(int(query[1]) - 1, {query[2]})
        else:
            l, r = int(query[1])-1, int(query[2])
            print(len(segtree.query(l, r))) query querys if query[0] == "1":
            segtree.update(int(query[1]) - 1, {query[2]})
        else:
            l, r = int(query[1])-1, int(query[2])
            print(len(segtree.query(l, r))) query[0] == "1" query[0] query 0 "1" segtree.update(int(query[1]) - 1, {query[2]}) segtree.update segtree update int(query[1]) - 1 int(query[1]) int query[1] query 1 1 {query[2]} l, r = int(query[1])-1, int(query[2]) l int(query[1])-1 int(query[1]) int query[1] query 1 1 r int(query[2]) int query[2] query 2 print(len(segtree.query(l, r))) print len(segtree.query(l, r)) len segtree.query(l, r) segtree.query segtree query l r if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input NLI = lambda: list(NMI()) lambda: list(NMI()) NLI def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# SegTreeの関数 def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# SegTreeの関数 make_grid NI = lambda: int(input()) lambda: int(input()) NI def main():
    N = NI()
    S = SI()
    Q = NI()
    querys = [list(SI().split()) for _ in range(Q)]
    S_sets = []
    for s in S:
        tmp = set()
        tmp.add(s)
        S_sets.append(tmp)

    segtree = SegTree(S_sets, segfunc, ide_ele)

    for query in querys:
        if query[0] == "1":
            segtree.update(int(query[1]) - 1, {query[2]})
        else:
            l, r = int(query[1])-1, int(query[2])
            print(len(segtree.query(l, r))) def main():
    N = NI()
    S = SI()
    Q = NI()
    querys = [list(SI().split()) for _ in range(Q)]
    S_sets = []
    for s in S:
        tmp = set()
        tmp.add(s)
        S_sets.append(tmp)

    segtree = SegTree(S_sets, segfunc, ide_ele)

    for query in querys:
        if query[0] == "1":
            segtree.update(int(query[1]) - 1, {query[2]})
        else:
            l, r = int(query[1])-1, int(query[2])
            print(len(segtree.query(l, r))) main NMI = lambda: map(int, input().split()) lambda: map(int, input().split()) NMI class SegTree:
    """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
        return res class SegTree:
    """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
        return res SegTree ide_ele = set() set() ide_ele def segfunc(x, y):
    return x | y
# 単位元
# min->inf, max->-inf, add->0, mul->1 def segfunc(x, y):
    return x | y
# 単位元
# min->inf, max->-inf, add->0, mul->1 segfunc MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD SI = lambda: input() lambda: input() SI
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# SegTreeの関数
def segfunc(x, y):
    return x | y
# 単位元
# min->inf, max->-inf, add->0, mul->1
ide_ele = set()

# セグメント木
class SegTree:
    """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
        return res


def main():
    N = NI()
    S = SI()
    Q = NI()
    querys = [list(SI().split()) for _ in range(Q)]
    S_sets = []
    for s in S:
        tmp = set()
        tmp.add(s)
        S_sets.append(tmp)

    segtree = SegTree(S_sets, segfunc, ide_ele)

    for query in querys:
        if query[0] == "1":
            segtree.update(int(query[1]) - 1, {query[2]})
        else:
            l, r = int(query[1])-1, int(query[2])
            print(len(segtree.query(l, r)))



if __name__ == "__main__":
    main()