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

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

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

n = int(input())
s = input()
q = int(input())

bit = [BIT(n+1) for i in range(26)]
for i in range(n):
    bit[ord(s[i])-97].add(i+1, 1)


s = list(s)
for _ in range(q):
    query, a, b = input().split()
    if query == "1":
        i = int(a)
        c = ord(b)-97
        bit[c].add(i, 1)

        bit[ord(s[i-1])-97].add(i, -1)
        s[i-1] = b
    else:
        ans = 0
        for k in range(26):
            if bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1:
                ans += 1
        print(ans) class BIT():
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n+1)

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

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

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

     sum s = 0 s 0 while i > 0:
            s += self.bit[i]
            i -= i & -i
         i > 0 i 0 s += self.bit[i] s self.bit[i] self.bit self bit 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.bit[i] += x
            i += i & -i add while i <= self.size:
            self.bit[i] += x
            i += i & -i i <= self.size i self.size self size self.bit[i] += x self.bit[i] self.bit self bit i x i += i & -i i i & -i i -i i self self i i x x n = int(input()) n int(input()) int input() input s = input() s input() input q = int(input()) q int(input()) int input() input BIT(n+1) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) BIT(n+1) BIT n+1 n 1 bit = [BIT(n+1) for i in range(26)] bit [BIT(n+1) for i in range(26)] for i in range(n):
    bit[ord(s[i])-97].add(i+1, 1) i range(n) range n bit[ord(s[i])-97].add(i+1, 1) [ord(s[i])-97].add [ord(s[i])-97] bit ord(s[i])-97 ord(s[i]) ord s[i] s i 97 add i+1 i 1 1 s = list(s) s list(s) list s for _ in range(q):
    query, a, b = input().split()
    if query == "1":
        i = int(a)
        c = ord(b)-97
        bit[c].add(i, 1)

        bit[ord(s[i-1])-97].add(i, -1)
        s[i-1] = b
    else:
        ans = 0
        for k in range(26):
            if bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1:
                ans += 1
        print(ans) _ range(q) range q query, a, b = input().split() query input().split() ().split () input split a b if query == "1":
        i = int(a)
        c = ord(b)-97
        bit[c].add(i, 1)

        bit[ord(s[i-1])-97].add(i, -1)
        s[i-1] = b
    else:
        ans = 0
        for k in range(26):
            if bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1:
                ans += 1
        print(ans) query == "1" query "1" i = int(a) i int(a) int a c = ord(b)-97 c ord(b)-97 ord(b) ord b 97 bit[c].add(i, 1) [c].add [c] bit c add i 1 bit[ord(s[i-1])-97].add(i, -1) [ord(s[i-1])-97].add [ord(s[i-1])-97] bit ord(s[i-1])-97 ord(s[i-1]) ord s[i-1] s i-1 i 1 97 add i -1 s[i-1] = b s[i-1] s i-1 i 1 b ans = 0 ans 0 for k in range(26):
            if bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1:
                ans += 1
         k range(26) range 26 if bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1:
                ans += 1
         bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1 bit[k].sum(int(b))-bit[k].sum(int(a)-1) bit[k].sum(int(b)) [k].sum [k] bit k sum int(b) int b bit[k].sum(int(a)-1) [k].sum [k] bit k sum int(a)-1 int(a) int a 1 1 ans += 1 ans 1 print(ans) print ans s = input() input() s bit = [BIT(n+1) for i in range(26)] [BIT(n+1) for i in range(26)] bit ans += 1 1 ans class BIT():
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n+1)

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

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

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

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += i & -i BIT a, b = input().split() input().split() a c = ord(b)-97 ord(b)-97 c query, a, b = input().split() input().split() query b = input().split() input().split() b n = int(input()) int(input()) n q = int(input()) int(input()) q ans = 0 0 ans s = list(s) list(s) s i = int(a) int(a) i
#1indexed
class BIT():
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n+1)

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

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

n = int(input())
s = input()
q = int(input())

bit = [BIT(n+1) for i in range(26)]
for i in range(n):
    bit[ord(s[i])-97].add(i+1, 1)


s = list(s)
for _ in range(q):
    query, a, b = input().split()
    if query == "1":
        i = int(a)
        c = ord(b)-97
        bit[c].add(i, 1)

        bit[ord(s[i-1])-97].add(i, -1)
        s[i-1] = b
    else:
        ans = 0
        for k in range(26):
            if bit[k].sum(int(b))-bit[k].sum(int(a)-1) >= 1:
                ans += 1
        print(ans)
