class SegmentTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size, initValue):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue

    def cmpFunc(self, left, right):
        return left | right

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

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

N = int(input())
S = list(map(cToI, input()))

S = [1 << s for s in S]
tree = SegmentTree(N, 0)
tree.build(S)

Q = int(input())
ans = []
for _ in range(Q):
    q1, q2, q3 = input().split()

    if q1 == '1':
        tree.update(int(q2) - 1, 1 << cToI(q3))
    else:
        ans.append(tree.query(int(q2) - 1, int(q3)))

for a in ans:
    cnt = 0
    while a > 0:
        cnt += a % 2
        a //= 2
    print(cnt) class SegmentTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size, initValue):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue

    def cmpFunc(self, left, right):
        return left | right

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret SegmentTree """
    0-indexed
    query : [L, R)
    """ def __init__(self, size, initValue):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue

     __init__ self.size = 1 << (size.bit_length()) self.size self size 1 << (size.bit_length()) 1 size.bit_length() size.bit_length size bit_length self.data = [initValue] * (2 * self.size - 1) self.data self data [initValue] * (2 * self.size - 1) [initValue] initValue 2 * self.size - 1 2 * self.size 2 self.size self size 1 self.initValue = initValue self.initValue self initValue initValue self self size size initValue initValue def cmpFunc(self, left, right):
        return left | right

     cmpFunc return left | right left | right left right self self left left right right def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

     build self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData self.data[self.size - 1: self.size - 1 + len(rawData)] self.data self data self.size - 1: self.size - 1 + len(rawData) self.size - 1 self.size self size 1 self.size - 1 + len(rawData) self.size - 1 self.size self size 1 len(rawData) len rawData rawData for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

     i range(self.size - 1)[:: -1] (self.size - 1) range self.size - 1 self.size self size 1 :: -1 -1 self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2]) self.data[i] self.data self data i self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2]) self.cmpFunc self cmpFunc self.data[2 * i + 1] self.data self data 2 * i + 1 2 * i 2 i 1 self.data[2 * i + 2] self.data self data 2 * i + 2 2 * i 2 i 2 self self rawData rawData def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

     update index += self.size - 1 index self.size - 1 self.size self size 1 self.data[index] = value self.data[index] self.data self data index value while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

     index >= 0 index 0 index = (index - 1) // 2 index (index - 1) // 2 index - 1 index 1 2 self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2]) self.data[index] self.data self data index self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2]) self.cmpFunc self cmpFunc self.data[2 * index + 1] self.data self data 2 * index + 1 2 * index 2 index 1 self.data[2 * index + 2] self.data self data 2 * index + 2 2 * index 2 index 2 self self index index value value def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret query L = left + self.size L left + self.size left self.size self size R = right + self.size R right + self.size right self.size self size ret = self.initValue ret self.initValue self initValue while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
         L < R L R if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
             R & 1 R 1 R -= 1 R 1 ret = self.cmpFunc(ret, self.data[R - 1]) ret self.cmpFunc(ret, self.data[R - 1]) self.cmpFunc self cmpFunc ret self.data[R - 1] self.data self data R - 1 R 1 if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
             L & 1 L 1 ret = self.cmpFunc(ret, self.data[L - 1]) ret self.cmpFunc(ret, self.data[L - 1]) self.cmpFunc self cmpFunc ret self.data[L - 1] self.data self data L - 1 L 1 L += 1 L 1 L >>= 1 L 1 R >>= 1 R 1 return ret ret self self left left right right def cToI(s):
    return ord(s) - ord('a') cToI 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 = list(map(cToI, input())) S list(map(cToI, input())) list map(cToI, input()) map cToI input() input 1 << s for s in S for s in S s S for s in S 1 << s 1 s S = [1 << s for s in S] S [1 << s for s in S] tree = SegmentTree(N, 0) tree SegmentTree(N, 0) SegmentTree N 0 tree.build(S) tree.build tree build S Q = int(input()) Q int(input()) int input() input ans = [] ans [] for _ in range(Q):
    q1, q2, q3 = input().split()

    if q1 == '1':
        tree.update(int(q2) - 1, 1 << cToI(q3))
    else:
        ans.append(tree.query(int(q2) - 1, int(q3))) _ range(Q) range Q q1, q2, q3 = input().split() q1 input().split() ().split () input split q2 q3 if q1 == '1':
        tree.update(int(q2) - 1, 1 << cToI(q3))
    else:
        ans.append(tree.query(int(q2) - 1, int(q3))) q1 == '1' q1 '1' tree.update(int(q2) - 1, 1 << cToI(q3)) tree.update tree update int(q2) - 1 int(q2) int q2 1 1 << cToI(q3) 1 cToI(q3) cToI q3 ans.append(tree.query(int(q2) - 1, int(q3))) ans.append ans append tree.query(int(q2) - 1, int(q3)) tree.query tree query int(q2) - 1 int(q2) int q2 1 int(q3) int q3 for a in ans:
    cnt = 0
    while a > 0:
        cnt += a % 2
        a //= 2
    print(cnt) a ans cnt = 0 cnt 0 while a > 0:
        cnt += a % 2
        a //= 2
     a > 0 a 0 cnt += a % 2 cnt a % 2 a 2 a //= 2 a 2 print(cnt) print cnt q1, q2, q3 = input().split() input().split() q1 q2, q3 = input().split() input().split() q2 ans = [] [] ans a //= 2 2 a S = [1 << s for s in S] [1 << s for s in S] S class SegmentTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size, initValue):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue

    def cmpFunc(self, left, right):
        return left | right

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret class SegmentTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size, initValue):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue

    def cmpFunc(self, left, right):
        return left | right

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret SegmentTree cnt += a % 2 a % 2 cnt q3 = input().split() input().split() q3 N = int(input()) int(input()) N def cToI(s):
    return ord(s) - ord('a') def cToI(s):
    return ord(s) - ord('a') cToI cnt = 0 0 cnt S = list(map(cToI, input())) list(map(cToI, input())) S Q = int(input()) int(input()) Q tree = SegmentTree(N, 0) SegmentTree(N, 0) tree
class SegmentTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size, initValue):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue

    def cmpFunc(self, left, right):
        return left | right

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

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

N = int(input())
S = list(map(cToI, input()))

S = [1 << s for s in S]
tree = SegmentTree(N, 0)
tree.build(S)

Q = int(input())
ans = []
for _ in range(Q):
    q1, q2, q3 = input().split()

    if q1 == '1':
        tree.update(int(q2) - 1, 1 << cToI(q3))
    else:
        ans.append(tree.query(int(q2) - 1, int(q3)))

for a in ans:
    cnt = 0
    while a > 0:
        cnt += a % 2
        a //= 2
    print(cnt)
