import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# from numba import jit

# from scipy import
# import numpy as np
# import networkx as nx

# import matplotlib.pyplot as plt

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class SegmentTree:

    def __init__(self, array, operator, identity):
        self.identity = identity
        self.operator = operator

        self.array_size = len(array)
        self.tree_height = (self.array_size - 1).bit_length()
        self.tree_size = 2 ** (self.tree_height + 1)
        self.leaf_start_index = 2 ** self.tree_height
        self.tree = [self.identity] * self.tree_size

        for i in range(self.array_size):
            x = 1 << (ord(array[i]) - 96)
            self.tree[self.leaf_start_index + i] = x

        for i in range(self.leaf_start_index - 1, 0, -1):
            self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1])

    def update(self, index, val):
        x = 1 << (ord(val) - 96)

        cur_node = self.leaf_start_index + index
        self.tree[cur_node] = x

        while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

    def query(self, begin, end):
        if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity
        if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

        res = self.identity

        left = begin + self.leaf_start_index
        right = end + self.leaf_start_index

        while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

        return res


def main():
    from operator import or_
    n = int(input())
    s = input()
    q = int(input())

    seg = SegmentTree(s, or_, 0)

    for i in range(q):
        q1, q2, q3 = readline().split()
        q1, q2 = int(q1), int(q2)
        if q1 == 1:
            seg.update(q2-1, q3.rstrip("\n"))
        else:
            q3 = int(q3)
            print(bin(seg.query(q2-1, q3)).count("1"))


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 class SegmentTree:

    def __init__(self, array, operator, identity):
        self.identity = identity
        self.operator = operator

        self.array_size = len(array)
        self.tree_height = (self.array_size - 1).bit_length()
        self.tree_size = 2 ** (self.tree_height + 1)
        self.leaf_start_index = 2 ** self.tree_height
        self.tree = [self.identity] * self.tree_size

        for i in range(self.array_size):
            x = 1 << (ord(array[i]) - 96)
            self.tree[self.leaf_start_index + i] = x

        for i in range(self.leaf_start_index - 1, 0, -1):
            self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1])

    def update(self, index, val):
        x = 1 << (ord(val) - 96)

        cur_node = self.leaf_start_index + index
        self.tree[cur_node] = x

        while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

    def query(self, begin, end):
        if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity
        if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

        res = self.identity

        left = begin + self.leaf_start_index
        right = end + self.leaf_start_index

        while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

        return res SegmentTree def __init__(self, array, operator, identity):
        self.identity = identity
        self.operator = operator

        self.array_size = len(array)
        self.tree_height = (self.array_size - 1).bit_length()
        self.tree_size = 2 ** (self.tree_height + 1)
        self.leaf_start_index = 2 ** self.tree_height
        self.tree = [self.identity] * self.tree_size

        for i in range(self.array_size):
            x = 1 << (ord(array[i]) - 96)
            self.tree[self.leaf_start_index + i] = x

        for i in range(self.leaf_start_index - 1, 0, -1):
            self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1])

     __init__ self.identity = identity self.identity self identity identity self.operator = operator self.operator self operator operator self.array_size = len(array) self.array_size self array_size len(array) len array self.tree_height = (self.array_size - 1).bit_length() self.tree_height self tree_height (self.array_size - 1).bit_length() self.array_size - 1).bit_length self.array_size - 1 self.array_size self array_size 1 bit_length self.tree_size = 2 ** (self.tree_height + 1) self.tree_size self tree_size 2 ** (self.tree_height + 1) 2 self.tree_height + 1 self.tree_height self tree_height 1 self.leaf_start_index = 2 ** self.tree_height self.leaf_start_index self leaf_start_index 2 ** self.tree_height 2 self.tree_height self tree_height self.tree = [self.identity] * self.tree_size self.tree self tree [self.identity] * self.tree_size [self.identity] self.identity self identity self.tree_size self tree_size for i in range(self.array_size):
            x = 1 << (ord(array[i]) - 96)
            self.tree[self.leaf_start_index + i] = x

         i range(self.array_size) range self.array_size self array_size x = 1 << (ord(array[i]) - 96) x 1 << (ord(array[i]) - 96) 1 ord(array[i]) - 96 ord(array[i]) ord array[i] array i 96 self.tree[self.leaf_start_index + i] = x self.tree[self.leaf_start_index + i] self.tree self tree self.leaf_start_index + i self.leaf_start_index self leaf_start_index i x for i in range(self.leaf_start_index - 1, 0, -1):
            self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1])

     i range(self.leaf_start_index - 1, 0, -1) range self.leaf_start_index - 1 self.leaf_start_index self leaf_start_index 1 0 -1 self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1]) self.tree[i] self.tree self tree i self.operator(self.tree[i << 1], self.tree[i << 1 | 1]) self.operator self operator 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 array array operator operator identity identity def update(self, index, val):
        x = 1 << (ord(val) - 96)

        cur_node = self.leaf_start_index + index
        self.tree[cur_node] = x

        while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

     update x = 1 << (ord(val) - 96) x 1 << (ord(val) - 96) 1 ord(val) - 96 ord(val) ord val 96 cur_node = self.leaf_start_index + index cur_node self.leaf_start_index + index self.leaf_start_index self leaf_start_index index self.tree[cur_node] = x self.tree[cur_node] self.tree self tree cur_node x while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

     cur_node > 1 cur_node 1 self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1]) self.tree[cur_node >> 1] self.tree self tree cur_node >> 1 cur_node 1 self.operator(self.tree[cur_node], self.tree[cur_node ^ 1]) self.operator self operator self.tree[cur_node] self.tree self tree cur_node self.tree[cur_node ^ 1] self.tree self tree cur_node ^ 1 cur_node 1 cur_node >>= 1 cur_node 1 self self index index val val def query(self, begin, end):
        if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity
        if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

        res = self.identity

        left = begin + self.leaf_start_index
        right = end + self.leaf_start_index

        while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

        return res query if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity
         begin < 0 begin 0 begin = 0 begin 0 elif begin > self.array_size:
            return self.identity
         begin > self.array_size begin self.array_size self array_size return self.identity self.identity self identity if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

         end > self.array_size end self.array_size self array_size end = self.array_size end self.array_size self array_size elif end < 1:
            return self.identity

         end < 1 end 1 return self.identity self.identity self identity res = self.identity res self.identity self identity left = begin + self.leaf_start_index left begin + self.leaf_start_index begin self.leaf_start_index self leaf_start_index right = end + self.leaf_start_index right end + self.leaf_start_index end self.leaf_start_index self leaf_start_index while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

         left < right left right if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

             left & 1 left 1 res = self.operator(res, self.tree[left]) res self.operator(res, self.tree[left]) self.operator self operator res self.tree[left] self.tree self tree left left += 1 left 1 if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

             right & 1 right 1 right -= 1 right 1 res = self.operator(res, self.tree[right]) res self.operator(res, self.tree[right]) self.operator self operator res self.tree[right] self.tree self tree right left >>= 1 left 1 right >>= 1 right 1 return res res self self begin begin end end def main():
    from operator import or_
    n = int(input())
    s = input()
    q = int(input())

    seg = SegmentTree(s, or_, 0)

    for i in range(q):
        q1, q2, q3 = readline().split()
        q1, q2 = int(q1), int(q2)
        if q1 == 1:
            seg.update(q2-1, q3.rstrip("\n"))
        else:
            q3 = int(q3)
            print(bin(seg.query(q2-1, q3)).count("1")) main from operator import or_ n = int(input()) n int(input()) int input() input s = input() s input() input q = int(input()) q int(input()) int input() input seg = SegmentTree(s, or_, 0) seg SegmentTree(s, or_, 0) SegmentTree s or_ 0 for i in range(q):
        q1, q2, q3 = readline().split()
        q1, q2 = int(q1), int(q2)
        if q1 == 1:
            seg.update(q2-1, q3.rstrip("\n"))
        else:
            q3 = int(q3)
            print(bin(seg.query(q2-1, q3)).count("1")) i range(q) range q q1, q2, q3 = readline().split() q1 readline().split() ().split () readline split q2 q3 q1, q2 = int(q1), int(q2) q1 int(q1) int q1 q2 int(q2) int q2 if q1 == 1:
            seg.update(q2-1, q3.rstrip("\n"))
        else:
            q3 = int(q3)
            print(bin(seg.query(q2-1, q3)).count("1")) q1 == 1 q1 1 seg.update(q2-1, q3.rstrip("\n")) seg.update seg update q2-1 q2 1 q3.rstrip("\n") q3.rstrip q3 rstrip "\n" q3 = int(q3) q3 int(q3) int q3 print(bin(seg.query(q2-1, q3)).count("1")) print bin(seg.query(q2-1, q3)).count("1") (seg.query(q2-1, q3)).count (seg.query(q2-1, q3)) bin seg.query(q2-1, q3) seg.query seg query q2-1 q2 1 q3 count "1" if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main class SegmentTree:

    def __init__(self, array, operator, identity):
        self.identity = identity
        self.operator = operator

        self.array_size = len(array)
        self.tree_height = (self.array_size - 1).bit_length()
        self.tree_size = 2 ** (self.tree_height + 1)
        self.leaf_start_index = 2 ** self.tree_height
        self.tree = [self.identity] * self.tree_size

        for i in range(self.array_size):
            x = 1 << (ord(array[i]) - 96)
            self.tree[self.leaf_start_index + i] = x

        for i in range(self.leaf_start_index - 1, 0, -1):
            self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1])

    def update(self, index, val):
        x = 1 << (ord(val) - 96)

        cur_node = self.leaf_start_index + index
        self.tree[cur_node] = x

        while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

    def query(self, begin, end):
        if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity
        if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

        res = self.identity

        left = begin + self.leaf_start_index
        right = end + self.leaf_start_index

        while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

        return res class SegmentTree:

    def __init__(self, array, operator, identity):
        self.identity = identity
        self.operator = operator

        self.array_size = len(array)
        self.tree_height = (self.array_size - 1).bit_length()
        self.tree_size = 2 ** (self.tree_height + 1)
        self.leaf_start_index = 2 ** self.tree_height
        self.tree = [self.identity] * self.tree_size

        for i in range(self.array_size):
            x = 1 << (ord(array[i]) - 96)
            self.tree[self.leaf_start_index + i] = x

        for i in range(self.leaf_start_index - 1, 0, -1):
            self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1])

    def update(self, index, val):
        x = 1 << (ord(val) - 96)

        cur_node = self.leaf_start_index + index
        self.tree[cur_node] = x

        while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

    def query(self, begin, end):
        if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity
        if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

        res = self.identity

        left = begin + self.leaf_start_index
        right = end + self.leaf_start_index

        while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

        return res SegmentTree MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD readline = sys.stdin.readline sys.stdin.readline readline INF = float('INF') float('INF') INF def main():
    from operator import or_
    n = int(input())
    s = input()
    q = int(input())

    seg = SegmentTree(s, or_, 0)

    for i in range(q):
        q1, q2, q3 = readline().split()
        q1, q2 = int(q1), int(q2)
        if q1 == 1:
            seg.update(q2-1, q3.rstrip("\n"))
        else:
            q3 = int(q3)
            print(bin(seg.query(q2-1, q3)).count("1")) def main():
    from operator import or_
    n = int(input())
    s = input()
    q = int(input())

    seg = SegmentTree(s, or_, 0)

    for i in range(q):
        q1, q2, q3 = readline().split()
        q1, q2 = int(q1), int(q2)
        if q1 == 1:
            seg.update(q2-1, q3.rstrip("\n"))
        else:
            q3 = int(q3)
            print(bin(seg.query(q2-1, q3)).count("1")) main
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# from numba import jit

# from scipy import
# import numpy as np
# import networkx as nx

# import matplotlib.pyplot as plt

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class SegmentTree:

    def __init__(self, array, operator, identity):
        self.identity = identity
        self.operator = operator

        self.array_size = len(array)
        self.tree_height = (self.array_size - 1).bit_length()
        self.tree_size = 2 ** (self.tree_height + 1)
        self.leaf_start_index = 2 ** self.tree_height
        self.tree = [self.identity] * self.tree_size

        for i in range(self.array_size):
            x = 1 << (ord(array[i]) - 96)
            self.tree[self.leaf_start_index + i] = x

        for i in range(self.leaf_start_index - 1, 0, -1):
            self.tree[i] = self.operator(self.tree[i << 1], self.tree[i << 1 | 1])

    def update(self, index, val):
        x = 1 << (ord(val) - 96)

        cur_node = self.leaf_start_index + index
        self.tree[cur_node] = x

        while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

    def query(self, begin, end):
        if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity
        if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

        res = self.identity

        left = begin + self.leaf_start_index
        right = end + self.leaf_start_index

        while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

        return res


def main():
    from operator import or_
    n = int(input())
    s = input()
    q = int(input())

    seg = SegmentTree(s, or_, 0)

    for i in range(q):
        q1, q2, q3 = readline().split()
        q1, q2 = int(q1), int(q2)
        if q1 == 1:
            seg.update(q2-1, q3.rstrip("\n"))
        else:
            q3 = int(q3)
            print(bin(seg.query(q2-1, q3)).count("1"))


if __name__ == '__main__':
    main()
