N = int(input())
S = list(input())
Q = int(input())


class Bit:
    """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


en2asc = lambda s: ord(s) - 97

Bits = [Bit(N) for _ in range(26)]
for i, s in enumerate(S):
    Bits[en2asc(s)].add(i + 1, 1)

for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        i, c = int(q[1]), q[2]
        old = S[i - 1]
        Bits[en2asc(old)].add(i, -1)
        Bits[en2asc(c)].add(i, 1)
        S[i - 1] = c
    else:
        l, r = int(q[1]), int(q[2])
        ans = 0
        for b in Bits:
            ans += bool(b.sum(r) - b.sum(l - 1))
        print(ans) 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 class Bit:
    """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 Bit """1-indexed""" 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 en2asc = lambda s: ord(s) - 97 en2asc lambda s: ord(s) - 97 ord(s) - 97 ord(s) ord s 97 s Bit(N) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) Bit(N) Bit N Bits = [Bit(N) for _ in range(26)] Bits [Bit(N) for _ in range(26)] for i, s in enumerate(S):
    Bits[en2asc(s)].add(i + 1, 1) i s enumerate(S) enumerate S Bits[en2asc(s)].add(i + 1, 1) [en2asc(s)].add [en2asc(s)] Bits en2asc(s) en2asc s add i + 1 i 1 1 for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        i, c = int(q[1]), q[2]
        old = S[i - 1]
        Bits[en2asc(old)].add(i, -1)
        Bits[en2asc(c)].add(i, 1)
        S[i - 1] = c
    else:
        l, r = int(q[1]), int(q[2])
        ans = 0
        for b in Bits:
            ans += bool(b.sum(r) - b.sum(l - 1))
        print(ans) _ range(Q) range Q q = input().split() q input().split() ().split () input split if q[0] == '1':
        i, c = int(q[1]), q[2]
        old = S[i - 1]
        Bits[en2asc(old)].add(i, -1)
        Bits[en2asc(c)].add(i, 1)
        S[i - 1] = c
    else:
        l, r = int(q[1]), int(q[2])
        ans = 0
        for b in Bits:
            ans += bool(b.sum(r) - b.sum(l - 1))
        print(ans) q[0] == '1' q[0] q 0 '1' i, c = int(q[1]), q[2] i int(q[1]) int q[1] q 1 c q[2] q 2 old = S[i - 1] old S[i - 1] S i - 1 i 1 Bits[en2asc(old)].add(i, -1) [en2asc(old)].add [en2asc(old)] Bits en2asc(old) en2asc old add i -1 Bits[en2asc(c)].add(i, 1) [en2asc(c)].add [en2asc(c)] Bits en2asc(c) en2asc c add i 1 S[i - 1] = c S[i - 1] S i - 1 i 1 c l, r = int(q[1]), int(q[2]) l int(q[1]) int q[1] q 1 r int(q[2]) int q[2] q 2 ans = 0 ans 0 for b in Bits:
            ans += bool(b.sum(r) - b.sum(l - 1))
         b Bits ans += bool(b.sum(r) - b.sum(l - 1)) ans bool(b.sum(r) - b.sum(l - 1)) bool 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 print(ans) print ans old = S[i - 1] S[i - 1] old class Bit:
    """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 Bit:
    """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 Bit i, c = int(q[1]), q[2] int(q[1]) i Q = int(input()) int(input()) Q S = list(input()) list(input()) S q = input().split() input().split() q c = int(q[1]), q[2] q[2] c l, r = int(q[1]), int(q[2]) int(q[1]) l N = int(input()) int(input()) N en2asc = lambda s: ord(s) - 97 lambda s: ord(s) - 97 en2asc ans = 0 0 ans ans += bool(b.sum(r) - b.sum(l - 1)) bool(b.sum(r) - b.sum(l - 1)) ans Bits = [Bit(N) for _ in range(26)] [Bit(N) for _ in range(26)] Bits r = int(q[1]), int(q[2]) int(q[2]) r
N = int(input())
S = list(input())
Q = int(input())


class Bit:
    """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


en2asc = lambda s: ord(s) - 97

Bits = [Bit(N) for _ in range(26)]
for i, s in enumerate(S):
    Bits[en2asc(s)].add(i + 1, 1)

for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        i, c = int(q[1]), q[2]
        old = S[i - 1]
        Bits[en2asc(old)].add(i, -1)
        Bits[en2asc(c)].add(i, 1)
        S[i - 1] = c
    else:
        l, r = int(q[1]), int(q[2])
        ans = 0
        for b in Bits:
            ans += bool(b.sum(r) - b.sum(l - 1))
        print(ans)
