from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return S().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1)


n = I()
s = list(S())
q = I()
D = defaultdict(lambda:BIT(n))
for j in range(n):
    D[s[j]].add(j, 1)

for _ in range(q):
    qi, i, c = LS()
    if qi == "1":
        i = int(i) - 1
        D[s[i]].add(i, -1)
        D[c].add(i, 1)
        s[i] = c
    else:
        l, r = int(i) - 1, int(c)
        ret = 0
        for k in range(97, 123):
            if D[chr(k)].interval_sum(l, r):
                ret += 1
        print(ret)



 from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math math import bisect bisect import random random from itertools import permutations, accumulate, combinations, product import sys sys from copy import deepcopy import string string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor from operator import mul from functools import reduce sys.setrecursionlimit(2147483647) sys.setrecursionlimit sys setrecursionlimit 2147483647 INF = 10 ** 20 INF 10 ** 20 10 20 def LI(): return list(map(int, sys.stdin.readline().split())) LI def I(): return int(sys.stdin.readline()) I def LS(): return S().split() LS def S(): return sys.stdin.readline().strip() S I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I def IR(n): return [I() for i in range(n)] IR n n LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI def LIR(n): return [LI() for i in range(n)] LIR n n S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S def SR(n): return [S() for i in range(n)] SR n n LS() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LS() LS def LSR(n): return [LS() for i in range(n)] LSR n n list(S()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(S()) list S() S def SRL(n): return [list(S()) for i in range(n)] SRL n n mod = 1000000007 mod 1000000007 class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1) BIT def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

     __init__ self.bit = [0] * size self.bit self bit [0] * size [0] 0 size self.size = size self.size self size size self.total = 0 self.total self total 0 self self size size def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

     add x = i + 1 x i + 1 i 1 self.total += w self.total self total w while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
         x <= self.size x self.size self size self.bit[x - 1] += w self.bit[x - 1] self.bit self bit x - 1 x 1 w x += x & -x x x & -x x -x x return self self i i w w def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

     sum res = 0 res 0 x = i + 1 x i + 1 i 1 while x:
            res += self.bit[x - 1]
            x -= x & -x
         x res += self.bit[x - 1] res self.bit[x - 1] self.bit self bit x - 1 x 1 x -= x & -x x x & -x x -x x return res res self self i i def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1) interval_sum return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1) self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1) i self.sum(j - 1) - self.sum(i - 1) self.sum(j - 1) self.sum self sum j - 1 j 1 self.sum(i - 1) self.sum self sum i - 1 i 1 self.sum(j - 1) self.sum self sum j - 1 j 1 self self i i j j n = I() n I() I s = list(S()) s list(S()) list S() S q = I() q I() I D = defaultdict(lambda:BIT(n)) D defaultdict(lambda:BIT(n)) defaultdict lambda:BIT(n) BIT(n) BIT n for j in range(n):
    D[s[j]].add(j, 1) j range(n) range n D[s[j]].add(j, 1) [s[j]].add [s[j]] D s[j] s j add j 1 for _ in range(q):
    qi, i, c = LS()
    if qi == "1":
        i = int(i) - 1
        D[s[i]].add(i, -1)
        D[c].add(i, 1)
        s[i] = c
    else:
        l, r = int(i) - 1, int(c)
        ret = 0
        for k in range(97, 123):
            if D[chr(k)].interval_sum(l, r):
                ret += 1
        print(ret) _ range(q) range q qi, i, c = LS() qi LS() LS i c if qi == "1":
        i = int(i) - 1
        D[s[i]].add(i, -1)
        D[c].add(i, 1)
        s[i] = c
    else:
        l, r = int(i) - 1, int(c)
        ret = 0
        for k in range(97, 123):
            if D[chr(k)].interval_sum(l, r):
                ret += 1
        print(ret) qi == "1" qi "1" i = int(i) - 1 i int(i) - 1 int(i) int i 1 D[s[i]].add(i, -1) [s[i]].add [s[i]] D s[i] s i add i -1 D[c].add(i, 1) [c].add [c] D c add i 1 s[i] = c s[i] s i c l, r = int(i) - 1, int(c) l int(i) - 1 int(i) int i 1 r int(c) int c ret = 0 ret 0 for k in range(97, 123):
            if D[chr(k)].interval_sum(l, r):
                ret += 1
         k range(97, 123) range 97 123 if D[chr(k)].interval_sum(l, r):
                ret += 1
         D[chr(k)].interval_sum(l, r) [chr(k)].interval_sum [chr(k)] D chr(k) chr k interval_sum l r ret += 1 ret 1 print(ret) print ret mod = 1000000007 1000000007 mod i, c = LS() LS() i s = list(S()) list(S()) s ret += 1 1 ret i = int(i) - 1 int(i) - 1 i def S(): return sys.stdin.readline().strip() def S(): return sys.stdin.readline().strip() S n = I() I() n def LS(): return S().split() def LS(): return S().split() LS def SR(n): return [S() for i in range(n)] def SR(n): return [S() for i in range(n)] SR def SRL(n): return [list(S()) for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] SRL l, r = int(i) - 1, int(c) int(i) - 1 l def LSR(n): return [LS() for i in range(n)] def LSR(n): return [LS() for i in range(n)] LSR def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I r = int(i) - 1, int(c) int(c) r INF = 10 ** 20 10 ** 20 INF q = I() I() q class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1) class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1) BIT ret = 0 0 ret c = LS() LS() c def IR(n): return [I() for i in range(n)] def IR(n): return [I() for i in range(n)] IR def LIR(n): return [LI() for i in range(n)] def LIR(n): return [LI() for i in range(n)] LIR qi, i, c = LS() LS() qi D = defaultdict(lambda:BIT(n)) defaultdict(lambda:BIT(n)) D def LI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) LI
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return S().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1)


n = I()
s = list(S())
q = I()
D = defaultdict(lambda:BIT(n))
for j in range(n):
    D[s[j]].add(j, 1)

for _ in range(q):
    qi, i, c = LS()
    if qi == "1":
        i = int(i) - 1
        D[s[i]].add(i, -1)
        D[c].add(i, 1)
        s[i] = c
    else:
        l, r = int(i) - 1, int(c)
        ret = 0
        for k in range(97, 123):
            if D[chr(k)].interval_sum(l, r):
                ret += 1
        print(ret)




