class SegmentTree(object):  # 1-indexed
    def __init__(self, size, S):
        self.len = 1 << size.bit_length()

        self.array = [0] * (2 * self.len)
        for i, s in enumerate(S):
            self.array[i + self.len] = 1 << (ord(s) - ord('a'))
        for i in range(self.len - 1, 0, -1):
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]

    def query1(self, i, x):
        i += self.len
        self.array[i] = 1 << (ord(x) - ord('a'))
        i >>= 1
        while i > 0:
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]
            i >>= 1

    def get(self, i):
        return self.array[i + self.len]

    def query(self, l, r, i, a, b):
        if l == a and r == b:
            return self.array[i]
        center = (a + b) // 2
        if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b)

    def query2(self, l, r):
        ans = self.query(l - 1, r, 1, 0, self.len)
        print(bin(ans).count('1'))


N = int(input())
S = input()
tree = SegmentTree(N, S)
Q = int(input())

for _ in range(Q):
    a, b, c = map(str, input().split())
    if a == "1":
        b = int(b)
        tree.query1(b-1, c)
    else:
        b = int(b)
        c = int(c)
        tree.query2(b, c) class SegmentTree(object):  # 1-indexed
    def __init__(self, size, S):
        self.len = 1 << size.bit_length()

        self.array = [0] * (2 * self.len)
        for i, s in enumerate(S):
            self.array[i + self.len] = 1 << (ord(s) - ord('a'))
        for i in range(self.len - 1, 0, -1):
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]

    def query1(self, i, x):
        i += self.len
        self.array[i] = 1 << (ord(x) - ord('a'))
        i >>= 1
        while i > 0:
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]
            i >>= 1

    def get(self, i):
        return self.array[i + self.len]

    def query(self, l, r, i, a, b):
        if l == a and r == b:
            return self.array[i]
        center = (a + b) // 2
        if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b)

    def query2(self, l, r):
        ans = self.query(l - 1, r, 1, 0, self.len)
        print(bin(ans).count('1')) SegmentTree def __init__(self, size, S):
        self.len = 1 << size.bit_length()

        self.array = [0] * (2 * self.len)
        for i, s in enumerate(S):
            self.array[i + self.len] = 1 << (ord(s) - ord('a'))
        for i in range(self.len - 1, 0, -1):
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]

     __init__ self.len = 1 << size.bit_length() self.len self len 1 << size.bit_length() 1 size.bit_length() size.bit_length size bit_length self.array = [0] * (2 * self.len) self.array self array [0] * (2 * self.len) [0] 0 2 * self.len 2 self.len self len for i, s in enumerate(S):
            self.array[i + self.len] = 1 << (ord(s) - ord('a'))
         i s enumerate(S) enumerate S self.array[i + self.len] = 1 << (ord(s) - ord('a')) self.array[i + self.len] self.array self array i + self.len i self.len self len 1 << (ord(s) - ord('a')) 1 ord(s) - ord('a') ord(s) ord s ord('a') ord 'a' for i in range(self.len - 1, 0, -1):
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]

     i range(self.len - 1, 0, -1) range self.len - 1 self.len self len 1 0 -1 self.array[i] = self.array[i * 2] | self.array[i * 2 + 1] self.array[i] self.array self array i self.array[i * 2] | self.array[i * 2 + 1] self.array[i * 2] self.array self array i * 2 i 2 self.array[i * 2 + 1] self.array self array i * 2 + 1 i * 2 i 2 1 self self size size S S def query1(self, i, x):
        i += self.len
        self.array[i] = 1 << (ord(x) - ord('a'))
        i >>= 1
        while i > 0:
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]
            i >>= 1

     query1 i += self.len i self.len self len self.array[i] = 1 << (ord(x) - ord('a')) self.array[i] self.array self array i 1 << (ord(x) - ord('a')) 1 ord(x) - ord('a') ord(x) ord x ord('a') ord 'a' i >>= 1 i 1 while i > 0:
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]
            i >>= 1

     i > 0 i 0 self.array[i] = self.array[i * 2] | self.array[i * 2 + 1] self.array[i] self.array self array i self.array[i * 2] | self.array[i * 2 + 1] self.array[i * 2] self.array self array i * 2 i 2 self.array[i * 2 + 1] self.array self array i * 2 + 1 i * 2 i 2 1 i >>= 1 i 1 self self i i x x def get(self, i):
        return self.array[i + self.len]

     get return self.array[i + self.len] self.array[i + self.len] self.array self array i + self.len i self.len self len self self i i def query(self, l, r, i, a, b):
        if l == a and r == b:
            return self.array[i]
        center = (a + b) // 2
        if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b)

     query if l == a and r == b:
            return self.array[i]
         l == a and r == b l == a l a r == b r b return self.array[i] self.array[i] self.array self array i center = (a + b) // 2 center (a + b) // 2 a + b a b 2 if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b)

     center >= r center r return self.query(l, r, i * 2, a, center) self.query(l, r, i * 2, a, center) self.query self query l r i * 2 i 2 a center elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
         center <= l center l return self.query(l, r, i * 2 + 1, center, b) self.query(l, r, i * 2 + 1, center, b) self.query self query l r i * 2 + 1 i * 2 i 2 1 center b return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b) self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b) self.query(l, center, i * 2, a, center) self.query self query l center i * 2 i 2 a center self.query(center, r, i * 2 + 1, center, b) self.query self query center r i * 2 + 1 i * 2 i 2 1 center b self self l l r r i i a a b b def query2(self, l, r):
        ans = self.query(l - 1, r, 1, 0, self.len)
        print(bin(ans).count('1')) query2 ans = self.query(l - 1, r, 1, 0, self.len) ans self.query(l - 1, r, 1, 0, self.len) self.query self query l - 1 l 1 r 1 0 self.len self len print(bin(ans).count('1')) print bin(ans).count('1') (ans).count (ans) bin ans count '1' self self l l r r object N = int(input()) N int(input()) int input() input S = input() S input() input tree = SegmentTree(N, S) tree SegmentTree(N, S) SegmentTree N S Q = int(input()) Q int(input()) int input() input for _ in range(Q):
    a, b, c = map(str, input().split())
    if a == "1":
        b = int(b)
        tree.query1(b-1, c)
    else:
        b = int(b)
        c = int(c)
        tree.query2(b, c) _ range(Q) range Q a, b, c = map(str, input().split()) a map(str, input().split()) map str input().split() ().split () input split b c if a == "1":
        b = int(b)
        tree.query1(b-1, c)
    else:
        b = int(b)
        c = int(c)
        tree.query2(b, c) a == "1" a "1" b = int(b) b int(b) int b tree.query1(b-1, c) tree.query1 tree query1 b-1 b 1 c b = int(b) b int(b) int b c = int(c) c int(c) int c tree.query2(b, c) tree.query2 tree query2 b c c = int(c) int(c) c b = int(b) int(b) b Q = int(input()) int(input()) Q c = map(str, input().split()) map(str, input().split()) c a, b, c = map(str, input().split()) map(str, input().split()) a b = int(b) int(b) b b, c = map(str, input().split()) map(str, input().split()) b class SegmentTree(object):  # 1-indexed
    def __init__(self, size, S):
        self.len = 1 << size.bit_length()

        self.array = [0] * (2 * self.len)
        for i, s in enumerate(S):
            self.array[i + self.len] = 1 << (ord(s) - ord('a'))
        for i in range(self.len - 1, 0, -1):
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]

    def query1(self, i, x):
        i += self.len
        self.array[i] = 1 << (ord(x) - ord('a'))
        i >>= 1
        while i > 0:
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]
            i >>= 1

    def get(self, i):
        return self.array[i + self.len]

    def query(self, l, r, i, a, b):
        if l == a and r == b:
            return self.array[i]
        center = (a + b) // 2
        if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b)

    def query2(self, l, r):
        ans = self.query(l - 1, r, 1, 0, self.len)
        print(bin(ans).count('1')) class SegmentTree(object):  # 1-indexed
    def __init__(self, size, S):
        self.len = 1 << size.bit_length()

        self.array = [0] * (2 * self.len)
        for i, s in enumerate(S):
            self.array[i + self.len] = 1 << (ord(s) - ord('a'))
        for i in range(self.len - 1, 0, -1):
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]

    def query1(self, i, x):
        i += self.len
        self.array[i] = 1 << (ord(x) - ord('a'))
        i >>= 1
        while i > 0:
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]
            i >>= 1

    def get(self, i):
        return self.array[i + self.len]

    def query(self, l, r, i, a, b):
        if l == a and r == b:
            return self.array[i]
        center = (a + b) // 2
        if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b)

    def query2(self, l, r):
        ans = self.query(l - 1, r, 1, 0, self.len)
        print(bin(ans).count('1')) SegmentTree N = int(input()) int(input()) N tree = SegmentTree(N, S) SegmentTree(N, S) tree S = input() input() S
class SegmentTree(object):  # 1-indexed
    def __init__(self, size, S):
        self.len = 1 << size.bit_length()

        self.array = [0] * (2 * self.len)
        for i, s in enumerate(S):
            self.array[i + self.len] = 1 << (ord(s) - ord('a'))
        for i in range(self.len - 1, 0, -1):
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]

    def query1(self, i, x):
        i += self.len
        self.array[i] = 1 << (ord(x) - ord('a'))
        i >>= 1
        while i > 0:
            self.array[i] = self.array[i * 2] | self.array[i * 2 + 1]
            i >>= 1

    def get(self, i):
        return self.array[i + self.len]

    def query(self, l, r, i, a, b):
        if l == a and r == b:
            return self.array[i]
        center = (a + b) // 2
        if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return self.query(l, center, i * 2, a, center) | self.query(center, r, i * 2 + 1, center, b)

    def query2(self, l, r):
        ans = self.query(l - 1, r, 1, 0, self.len)
        print(bin(ans).count('1'))


N = int(input())
S = input()
tree = SegmentTree(N, S)
Q = int(input())

for _ in range(Q):
    a, b, c = map(str, input().split())
    if a == "1":
        b = int(b)
        tree.query1(b-1, c)
    else:
        b = int(b)
        c = int(c)
        tree.query2(b, c)
