class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def Alp(s):
    return ord(s)-ord("a")


if __name__ == "__main__":
    N = int(input())
    S = list(input())
    Q = int(input())

    bit = [BinaryIndexTree(N) for _ in range(26)]
    for i, s in enumerate(S, start=1):
        bit[Alp(s)].add(i, 1)

    ans = []
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            i = int(q[1]) - 1
            c = q[2]

            bit[Alp(c)].add(i+1, 1)
            bit[Alp(S[i])].add(i+1, -1)
            S[i] = c
        else:
            l = int(q[1])
            r = int(q[2])
            tmp = 0
            for i in range(26):
                b = bit[i]
                if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
            ans.append(tmp)

    print(*ans, sep="\n") class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i BinaryIndexTree def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

     __init__ self.size = n self.size self size n self.tree = [0] * (n + 1) self.tree self tree [0] * (n + 1) [0] 0 n + 1 n 1 self self n n def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

     sum s = 0 s 0 while i > 0:
            s += self.tree[i]
            i -= i & -i
         i > 0 i 0 s += self.tree[i] s self.tree[i] self.tree self tree i i -= i & -i i i & -i i -i i return s s self self i i def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i add while i <= self.size:
            self.tree[i] += x
            i += i & -i i <= self.size i self.size self size self.tree[i] += x self.tree[i] self.tree self tree i x i += i & -i i i & -i i -i i self self i i x x def Alp(s):
    return ord(s)-ord("a") Alp return ord(s)-ord("a") ord(s)-ord("a") ord(s) ord s ord("a") ord "a" s s if __name__ == "__main__":
    N = int(input())
    S = list(input())
    Q = int(input())

    bit = [BinaryIndexTree(N) for _ in range(26)]
    for i, s in enumerate(S, start=1):
        bit[Alp(s)].add(i, 1)

    ans = []
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            i = int(q[1]) - 1
            c = q[2]

            bit[Alp(c)].add(i+1, 1)
            bit[Alp(S[i])].add(i+1, -1)
            S[i] = c
        else:
            l = int(q[1])
            r = int(q[2])
            tmp = 0
            for i in range(26):
                b = bit[i]
                if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
            ans.append(tmp)

    print(*ans, sep="\n") __name__ == "__main__" __name__ "__main__" 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 BinaryIndexTree(N) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) BinaryIndexTree(N) BinaryIndexTree N bit = [BinaryIndexTree(N) for _ in range(26)] bit [BinaryIndexTree(N) for _ in range(26)] for i, s in enumerate(S, start=1):
        bit[Alp(s)].add(i, 1)

     i s enumerate(S, start=1) enumerate S start=1 start 1 bit[Alp(s)].add(i, 1) [Alp(s)].add [Alp(s)] bit Alp(s) Alp s add i 1 ans = [] ans [] for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            i = int(q[1]) - 1
            c = q[2]

            bit[Alp(c)].add(i+1, 1)
            bit[Alp(S[i])].add(i+1, -1)
            S[i] = c
        else:
            l = int(q[1])
            r = int(q[2])
            tmp = 0
            for i in range(26):
                b = bit[i]
                if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
            ans.append(tmp)

     _ range(Q) range Q q = input().split() q input().split() ().split () input split if q[0] == "1":
            i = int(q[1]) - 1
            c = q[2]

            bit[Alp(c)].add(i+1, 1)
            bit[Alp(S[i])].add(i+1, -1)
            S[i] = c
        else:
            l = int(q[1])
            r = int(q[2])
            tmp = 0
            for i in range(26):
                b = bit[i]
                if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
            ans.append(tmp)

     q[0] == "1" q[0] q 0 "1" i = int(q[1]) - 1 i int(q[1]) - 1 int(q[1]) int q[1] q 1 1 c = q[2] c q[2] q 2 bit[Alp(c)].add(i+1, 1) [Alp(c)].add [Alp(c)] bit Alp(c) Alp c add i+1 i 1 1 bit[Alp(S[i])].add(i+1, -1) [Alp(S[i])].add [Alp(S[i])] bit Alp(S[i]) Alp S[i] S i add i+1 i 1 -1 S[i] = c S[i] S i c l = int(q[1]) l int(q[1]) int q[1] q 1 r = int(q[2]) r int(q[2]) int q[2] q 2 tmp = 0 tmp 0 for i in range(26):
                b = bit[i]
                if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
             i range(26) range 26 b = bit[i] b bit[i] bit i if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
             b.sum(r) - b.sum(l - 1) > 0 b.sum(r) - b.sum(l - 1) b.sum(r) b.sum b sum r b.sum(l - 1) b.sum b sum l - 1 l 1 0 tmp += 1 tmp 1 ans.append(tmp) ans.append ans append tmp print(*ans, sep="\n") print *ans ans sep="\n" sep "\n" class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i BinaryIndexTree ans = [] [] ans bit = [BinaryIndexTree(N) for _ in range(26)] [BinaryIndexTree(N) for _ in range(26)] bit tmp = 0 0 tmp N = int(input()) int(input()) N S = list(input()) list(input()) S def Alp(s):
    return ord(s)-ord("a") def Alp(s):
    return ord(s)-ord("a") Alp q = input().split() input().split() q tmp += 1 1 tmp b = bit[i] bit[i] b l = int(q[1]) int(q[1]) l Q = int(input()) int(input()) Q r = int(q[2]) int(q[2]) r i = int(q[1]) - 1 int(q[1]) - 1 i c = q[2] q[2] c
class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def Alp(s):
    return ord(s)-ord("a")


if __name__ == "__main__":
    N = int(input())
    S = list(input())
    Q = int(input())

    bit = [BinaryIndexTree(N) for _ in range(26)]
    for i, s in enumerate(S, start=1):
        bit[Alp(s)].add(i, 1)

    ans = []
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            i = int(q[1]) - 1
            c = q[2]

            bit[Alp(c)].add(i+1, 1)
            bit[Alp(S[i])].add(i+1, -1)
            S[i] = c
        else:
            l = int(q[1])
            r = int(q[2])
            tmp = 0
            for i in range(26):
                b = bit[i]
                if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
            ans.append(tmp)

    print(*ans, sep="\n")
