import sys
from collections import deque

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()


class Node:
    def __init__(self, begin, end):
        self.begin = begin
        self.end = end
        self.left = self.right = self.parent = None
        self.val = 0


class SegmentTree:
    INF = 2 ** 60

    def __init__(self, size):
        self.root = Node(0, size)
        self.leaves = [None] * size

        queue = deque()
        queue.append(self.root)

        while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

    def update(self, index, val):
        node = self.leaves[index]
        node.val = val
        while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

    def val(self, begin, end, node=None):
        if node is None:
            return self.val(begin, end, self.root)
        if begin <= node.begin and node.end <= end:
            return node.val
        if node.end <= begin or end <= node.begin:
            return 0
        return self.val(begin, end, node.left) | self.val(begin, end, node.right)


N = int(input())
S = list(input())
Q = int(input())
tree = SegmentTree(N)
for i, c in enumerate(S):
    tree.update(i, 1 << (ord(c) - ord('a')))
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        i, c = query[1:]
        i = int(i) - 1
        tree.update(i, 1 << (ord(c) - ord('a')))
    else:
        l, r = map(int, query[1:])
        print(bin(tree.val(l - 1, r)).count('1')) import sys sys from collections import deque sys.setrecursionlimit(100000000) sys.setrecursionlimit sys setrecursionlimit 100000000 input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip class Node:
    def __init__(self, begin, end):
        self.begin = begin
        self.end = end
        self.left = self.right = self.parent = None
        self.val = 0 Node def __init__(self, begin, end):
        self.begin = begin
        self.end = end
        self.left = self.right = self.parent = None
        self.val = 0 __init__ self.begin = begin self.begin self begin begin self.end = end self.end self end end self.left = self.right = self.parent = None self.left self left None = self.right = self.parent = None self.right self right None self.parent self parent self.val = 0 self.val self val 0 self self begin begin end end class SegmentTree:
    INF = 2 ** 60

    def __init__(self, size):
        self.root = Node(0, size)
        self.leaves = [None] * size

        queue = deque()
        queue.append(self.root)

        while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

    def update(self, index, val):
        node = self.leaves[index]
        node.val = val
        while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

    def val(self, begin, end, node=None):
        if node is None:
            return self.val(begin, end, self.root)
        if begin <= node.begin and node.end <= end:
            return node.val
        if node.end <= begin or end <= node.begin:
            return 0
        return self.val(begin, end, node.left) | self.val(begin, end, node.right) SegmentTree INF = 2 ** 60 INF 2 ** 60 2 60 def __init__(self, size):
        self.root = Node(0, size)
        self.leaves = [None] * size

        queue = deque()
        queue.append(self.root)

        while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

     __init__ self.root = Node(0, size) self.root self root Node(0, size) Node 0 size self.leaves = [None] * size self.leaves self leaves [None] * size [None] None size queue = deque() queue deque() deque queue.append(self.root) queue.append queue append self.root self root while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

     len(queue) > 0 len(queue) len queue 0 node = queue.popleft() node queue.popleft() queue.popleft queue popleft if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

     node.end - node.begin == 1 node.end - node.begin node.end node end node.begin node begin 1 self.leaves[node.begin] = node self.leaves[node.begin] self.leaves self leaves node.begin node begin node mid = (node.begin + node.end) // 2 mid (node.begin + node.end) // 2 node.begin + node.end node.begin node begin node.end node end 2 node.left = Node(node.begin, mid) node.left node left Node(node.begin, mid) Node node.begin node begin mid node.right = Node(mid, node.end) node.right node right Node(mid, node.end) Node mid node.end node end node.left.parent = node.right.parent = node node.left.parent node.left node left parent node = node.right.parent = node node.right.parent node.right node right parent node queue.append(node.left) queue.append queue append node.left node left queue.append(node.right) queue.append queue append node.right node right self self size size def update(self, index, val):
        node = self.leaves[index]
        node.val = val
        while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

     update node = self.leaves[index] node self.leaves[index] self.leaves self leaves index node.val = val node.val node val val while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

     node.parent is not None node.parent node parent None node = node.parent node node.parent node parent node.val = node.left.val | node.right.val node.val node val node.left.val | node.right.val node.left.val node.left node left val node.right.val node.right node right val self self index index val val def val(self, begin, end, node=None):
        if node is None:
            return self.val(begin, end, self.root)
        if begin <= node.begin and node.end <= end:
            return node.val
        if node.end <= begin or end <= node.begin:
            return 0
        return self.val(begin, end, node.left) | self.val(begin, end, node.right) val if node is None:
            return self.val(begin, end, self.root)
         node is None node None return self.val(begin, end, self.root) self.val(begin, end, self.root) self.val self val begin end self.root self root if begin <= node.begin and node.end <= end:
            return node.val
         begin <= node.begin and node.end <= end begin <= node.begin begin node.begin node begin node.end <= end node.end node end end return node.val node.val node val if node.end <= begin or end <= node.begin:
            return 0
         node.end <= begin or end <= node.begin node.end <= begin node.end node end begin end <= node.begin end node.begin node begin return 0 0 return self.val(begin, end, node.left) | self.val(begin, end, node.right) self.val(begin, end, node.left) | self.val(begin, end, node.right) self.val(begin, end, node.left) self.val self val begin end node.left node left self.val(begin, end, node.right) self.val self val begin end node.right node right self self begin begin end end node=None node None N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input Q = int(input()) Q int(input()) int input() input tree = SegmentTree(N) tree SegmentTree(N) SegmentTree N for i, c in enumerate(S):
    tree.update(i, 1 << (ord(c) - ord('a'))) i c enumerate(S) enumerate S tree.update(i, 1 << (ord(c) - ord('a'))) tree.update tree update i 1 << (ord(c) - ord('a')) 1 ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        i, c = query[1:]
        i = int(i) - 1
        tree.update(i, 1 << (ord(c) - ord('a')))
    else:
        l, r = map(int, query[1:])
        print(bin(tree.val(l - 1, r)).count('1')) _ range(Q) range Q query = input().split() query input().split() ().split () input split if query[0] == '1':
        i, c = query[1:]
        i = int(i) - 1
        tree.update(i, 1 << (ord(c) - ord('a')))
    else:
        l, r = map(int, query[1:])
        print(bin(tree.val(l - 1, r)).count('1')) query[0] == '1' query[0] query 0 '1' i, c = query[1:] i query[1:] query 1: 1 c i = int(i) - 1 i int(i) - 1 int(i) int i 1 tree.update(i, 1 << (ord(c) - ord('a'))) tree.update tree update i 1 << (ord(c) - ord('a')) 1 ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' l, r = map(int, query[1:]) l map(int, query[1:]) map int query[1:] query 1: 1 r print(bin(tree.val(l - 1, r)).count('1')) print bin(tree.val(l - 1, r)).count('1') (tree.val(l - 1, r)).count (tree.val(l - 1, r)) bin tree.val(l - 1, r) tree.val tree val l - 1 l 1 r count '1' N = int(input()) int(input()) N query = input().split() input().split() query input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input r = map(int, query[1:]) map(int, query[1:]) r class SegmentTree:
    INF = 2 ** 60

    def __init__(self, size):
        self.root = Node(0, size)
        self.leaves = [None] * size

        queue = deque()
        queue.append(self.root)

        while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

    def update(self, index, val):
        node = self.leaves[index]
        node.val = val
        while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

    def val(self, begin, end, node=None):
        if node is None:
            return self.val(begin, end, self.root)
        if begin <= node.begin and node.end <= end:
            return node.val
        if node.end <= begin or end <= node.begin:
            return 0
        return self.val(begin, end, node.left) | self.val(begin, end, node.right) class SegmentTree:
    INF = 2 ** 60

    def __init__(self, size):
        self.root = Node(0, size)
        self.leaves = [None] * size

        queue = deque()
        queue.append(self.root)

        while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

    def update(self, index, val):
        node = self.leaves[index]
        node.val = val
        while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

    def val(self, begin, end, node=None):
        if node is None:
            return self.val(begin, end, self.root)
        if begin <= node.begin and node.end <= end:
            return node.val
        if node.end <= begin or end <= node.begin:
            return 0
        return self.val(begin, end, node.left) | self.val(begin, end, node.right) SegmentTree c = query[1:] query[1:] c l, r = map(int, query[1:]) map(int, query[1:]) l Q = int(input()) int(input()) Q tree = SegmentTree(N) SegmentTree(N) tree i = int(i) - 1 int(i) - 1 i class Node:
    def __init__(self, begin, end):
        self.begin = begin
        self.end = end
        self.left = self.right = self.parent = None
        self.val = 0 class Node:
    def __init__(self, begin, end):
        self.begin = begin
        self.end = end
        self.left = self.right = self.parent = None
        self.val = 0 Node i, c = query[1:] query[1:] i S = list(input()) list(input()) S
import sys
from collections import deque

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()


class Node:
    def __init__(self, begin, end):
        self.begin = begin
        self.end = end
        self.left = self.right = self.parent = None
        self.val = 0


class SegmentTree:
    INF = 2 ** 60

    def __init__(self, size):
        self.root = Node(0, size)
        self.leaves = [None] * size

        queue = deque()
        queue.append(self.root)

        while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

    def update(self, index, val):
        node = self.leaves[index]
        node.val = val
        while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

    def val(self, begin, end, node=None):
        if node is None:
            return self.val(begin, end, self.root)
        if begin <= node.begin and node.end <= end:
            return node.val
        if node.end <= begin or end <= node.begin:
            return 0
        return self.val(begin, end, node.left) | self.val(begin, end, node.right)


N = int(input())
S = list(input())
Q = int(input())
tree = SegmentTree(N)
for i, c in enumerate(S):
    tree.update(i, 1 << (ord(c) - ord('a')))
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        i, c = query[1:]
        i = int(i) - 1
        tree.update(i, 1 << (ord(c) - ord('a')))
    else:
        l, r = map(int, query[1:])
        print(bin(tree.val(l - 1, r)).count('1'))
