import sys
input = sys.stdin.readline
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
x = "abcdefghijklmnopqrstuvwxyz"
N, = map(int, input().split())
d = dict()
for c in x:
    d[c] = Bit(N+1)

S = list(input().strip())
for i, c in enumerate(S):
    d[c].add(i+1, 1)

Q = int(input())
for _ in range(Q):
    t, a, b = input().split()
    if t == '1':
        i, c = int(a), b
        b = S[i-1]
        S[i-1] = c
        d[b].add(i, -1)
        d[c].add(i, 1)
    else:
        l, r = int(a), int(b)
        rr = 0
        for c in x:
            if d[c].sum(r) - d[c].sum(l-1) > 0:
                rr += 1
        print(rr) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 x = "abcdefghijklmnopqrstuvwxyz" x "abcdefghijklmnopqrstuvwxyz" N, = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split d = dict() d dict() dict for c in x:
    d[c] = Bit(N+1) c x d[c] = Bit(N+1) d[c] d c Bit(N+1) Bit N+1 N 1 S = list(input().strip()) S list(input().strip()) list input().strip() ().strip () input strip for i, c in enumerate(S):
    d[c].add(i+1, 1) i c enumerate(S) enumerate S d[c].add(i+1, 1) [c].add [c] d c add i+1 i 1 1 Q = int(input()) Q int(input()) int input() input for _ in range(Q):
    t, a, b = input().split()
    if t == '1':
        i, c = int(a), b
        b = S[i-1]
        S[i-1] = c
        d[b].add(i, -1)
        d[c].add(i, 1)
    else:
        l, r = int(a), int(b)
        rr = 0
        for c in x:
            if d[c].sum(r) - d[c].sum(l-1) > 0:
                rr += 1
        print(rr) _ range(Q) range Q t, a, b = input().split() t input().split() ().split () input split a b if t == '1':
        i, c = int(a), b
        b = S[i-1]
        S[i-1] = c
        d[b].add(i, -1)
        d[c].add(i, 1)
    else:
        l, r = int(a), int(b)
        rr = 0
        for c in x:
            if d[c].sum(r) - d[c].sum(l-1) > 0:
                rr += 1
        print(rr) t == '1' t '1' i, c = int(a), b i int(a) int a c b b = S[i-1] b S[i-1] S i-1 i 1 S[i-1] = c S[i-1] S i-1 i 1 c d[b].add(i, -1) [b].add [b] d b add i -1 d[c].add(i, 1) [c].add [c] d c add i 1 l, r = int(a), int(b) l int(a) int a r int(b) int b rr = 0 rr 0 for c in x:
            if d[c].sum(r) - d[c].sum(l-1) > 0:
                rr += 1
         c x if d[c].sum(r) - d[c].sum(l-1) > 0:
                rr += 1
         d[c].sum(r) - d[c].sum(l-1) > 0 d[c].sum(r) - d[c].sum(l-1) d[c].sum(r) [c].sum [c] d c sum r d[c].sum(l-1) [c].sum [c] d c sum l-1 l 1 0 rr += 1 rr 1 print(rr) print rr r = int(a), int(b) int(b) r rr = 0 0 rr Q = int(input()) int(input()) Q a, b = input().split() input().split() a t, a, b = input().split() input().split() t b = S[i-1] S[i-1] b 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 d = dict() dict() d b = input().split() input().split() b c = int(a), b b c N, = map(int, input().split()) map(int, input().split()) N input = sys.stdin.readline sys.stdin.readline input rr += 1 1 rr x = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" x l, r = int(a), int(b) int(a) l S = list(input().strip()) list(input().strip()) S i, c = int(a), b int(a) i
import sys
input = sys.stdin.readline
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
x = "abcdefghijklmnopqrstuvwxyz"
N, = map(int, input().split())
d = dict()
for c in x:
    d[c] = Bit(N+1)

S = list(input().strip())
for i, c in enumerate(S):
    d[c].add(i+1, 1)

Q = int(input())
for _ in range(Q):
    t, a, b = input().split()
    if t == '1':
        i, c = int(a), b
        b = S[i-1]
        S[i-1] = c
        d[b].add(i, -1)
        d[c].add(i, 1)
    else:
        l, r = int(a), int(b)
        rr = 0
        for c in x:
            if d[c].sum(r) - d[c].sum(l-1) > 0:
                rr += 1
        print(rr)
