import sys
input = sys.stdin.readline

N = int(input())
S = list(input().rstrip())
ord_a = ord("a")

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

bits = [Bit(N) for _ in range(26)]

for i in range(N):
    s = S[i]
    bits[ord(s) - ord_a].add(i + 1, 1)

Q = int(input())

for _ in range(Q):
    query = input().rstrip().split()
    if query[0] == "1":
        i, c = int(query[1]), query[2]
        bits[ord(S[i - 1]) - ord_a].add(i, -1)
        S[i - 1] = c
        bits[ord(S[i - 1]) - ord_a].add(i, 1)
    else:
        l, r = int(query[1]), int(query[2])
        res = 0
        for bit in bits:
            if l != 1:
                res += int(bit.sum(r) - bit.sum(l - 1) > 0)
            else:
                res += int(bit.sum(r) > 0)
        print(res) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input S = list(input().rstrip()) S list(input().rstrip()) list input().rstrip() ().rstrip () input rstrip ord_a = ord("a") ord_a ord("a") ord "a" class Bit:
    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 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 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 in range(N):
    s = S[i]
    bits[ord(s) - ord_a].add(i + 1, 1) i range(N) range N s = S[i] s S[i] S i bits[ord(s) - ord_a].add(i + 1, 1) [ord(s) - ord_a].add [ord(s) - ord_a] bits ord(s) - ord_a ord(s) ord s ord_a add i + 1 i 1 1 Q = int(input()) Q int(input()) int input() input for _ in range(Q):
    query = input().rstrip().split()
    if query[0] == "1":
        i, c = int(query[1]), query[2]
        bits[ord(S[i - 1]) - ord_a].add(i, -1)
        S[i - 1] = c
        bits[ord(S[i - 1]) - ord_a].add(i, 1)
    else:
        l, r = int(query[1]), int(query[2])
        res = 0
        for bit in bits:
            if l != 1:
                res += int(bit.sum(r) - bit.sum(l - 1) > 0)
            else:
                res += int(bit.sum(r) > 0)
        print(res) _ range(Q) range Q query = input().rstrip().split() query input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split if query[0] == "1":
        i, c = int(query[1]), query[2]
        bits[ord(S[i - 1]) - ord_a].add(i, -1)
        S[i - 1] = c
        bits[ord(S[i - 1]) - ord_a].add(i, 1)
    else:
        l, r = int(query[1]), int(query[2])
        res = 0
        for bit in bits:
            if l != 1:
                res += int(bit.sum(r) - bit.sum(l - 1) > 0)
            else:
                res += int(bit.sum(r) > 0)
        print(res) query[0] == "1" query[0] query 0 "1" i, c = int(query[1]), query[2] i int(query[1]) int query[1] query 1 c query[2] query 2 bits[ord(S[i - 1]) - ord_a].add(i, -1) [ord(S[i - 1]) - ord_a].add [ord(S[i - 1]) - ord_a] bits ord(S[i - 1]) - ord_a ord(S[i - 1]) ord S[i - 1] S i - 1 i 1 ord_a add i -1 S[i - 1] = c S[i - 1] S i - 1 i 1 c bits[ord(S[i - 1]) - ord_a].add(i, 1) [ord(S[i - 1]) - ord_a].add [ord(S[i - 1]) - ord_a] bits ord(S[i - 1]) - ord_a ord(S[i - 1]) ord S[i - 1] S i - 1 i 1 ord_a add i 1 l, r = int(query[1]), int(query[2]) l int(query[1]) int query[1] query 1 r int(query[2]) int query[2] query 2 res = 0 res 0 for bit in bits:
            if l != 1:
                res += int(bit.sum(r) - bit.sum(l - 1) > 0)
            else:
                res += int(bit.sum(r) > 0)
         bit bits if l != 1:
                res += int(bit.sum(r) - bit.sum(l - 1) > 0)
            else:
                res += int(bit.sum(r) > 0)
         l != 1 l 1 res += int(bit.sum(r) - bit.sum(l - 1) > 0) res int(bit.sum(r) - bit.sum(l - 1) > 0) int bit.sum(r) - bit.sum(l - 1) > 0 bit.sum(r) - bit.sum(l - 1) bit.sum(r) bit.sum bit sum r bit.sum(l - 1) bit.sum bit sum l - 1 l 1 0 res += int(bit.sum(r) > 0) res int(bit.sum(r) > 0) int bit.sum(r) > 0 bit.sum(r) bit.sum bit sum r 0 print(res) print res res = 0 0 res S = list(input().rstrip()) list(input().rstrip()) S ord_a = ord("a") ord("a") ord_a query = input().rstrip().split() input().rstrip().split() query class Bit:
    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:
    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 Q = int(input()) int(input()) Q s = S[i] S[i] s res += int(bit.sum(r) > 0) int(bit.sum(r) > 0) res l, r = int(query[1]), int(query[2]) int(query[1]) l res += int(bit.sum(r) - bit.sum(l - 1) > 0) int(bit.sum(r) - bit.sum(l - 1) > 0) res N = int(input()) int(input()) N r = int(query[1]), int(query[2]) int(query[2]) r i, c = int(query[1]), query[2] int(query[1]) i c = int(query[1]), query[2] query[2] c input = sys.stdin.readline sys.stdin.readline input bits = [Bit(N) for _ in range(26)] [Bit(N) for _ in range(26)] bits
import sys
input = sys.stdin.readline

N = int(input())
S = list(input().rstrip())
ord_a = ord("a")

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

bits = [Bit(N) for _ in range(26)]

for i in range(N):
    s = S[i]
    bits[ord(s) - ord_a].add(i + 1, 1)

Q = int(input())

for _ in range(Q):
    query = input().rstrip().split()
    if query[0] == "1":
        i, c = int(query[1]), query[2]
        bits[ord(S[i - 1]) - ord_a].add(i, -1)
        S[i - 1] = c
        bits[ord(S[i - 1]) - ord_a].add(i, 1)
    else:
        l, r = int(query[1]), int(query[2])
        res = 0
        for bit in bits:
            if l != 1:
                res += int(bit.sum(r) - bit.sum(l - 1) > 0)
            else:
                res += int(bit.sum(r) > 0)
        print(res)