class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

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

    def add(self, i, val):
        while i < self.n:
            self.data[i] += val
            i |= i + 1


N = int(input())
bit = BIT(N + 1)
for i, c in enumerate(input()):
    ind = ord(c) - ord("a")
    bit.add(i + 1, 1 << (ind * 20))
Q = int(input())
for _ in range(Q):
    parts = input().split()
    if parts[0] == "1":
        ind = int(parts[1])
        nval = 1 << ((ord(parts[2]) - ord("a")) * 20)
        val = bit.sum(ind) - bit.sum(ind - 1)
        bit.add(ind, nval - val)
    else:
        l, r = map(int, parts[1:])
        val = bit.sum(r) - bit.sum(l - 1)
        mask = (1 << 20) - 1
        ans = 0
        while val:
            if val & mask:
                ans += 1
            val >>= 20
        print(ans) class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

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

    def add(self, i, val):
        while i < self.n:
            self.data[i] += val
            i |= i + 1 BIT def __init__(self, n):
        self.n = n
        self.data = [0] * n

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

     sum res = 0 res 0 while i >= 0:
            res += self.data[i]
            i = (i & (i + 1)) - 1
         i >= 0 i 0 res += self.data[i] res self.data[i] self.data self data i i = (i & (i + 1)) - 1 i (i & (i + 1)) - 1 i & (i + 1) i i + 1 i 1 1 return res res self self i i def add(self, i, val):
        while i < self.n:
            self.data[i] += val
            i |= i + 1 add while i < self.n:
            self.data[i] += val
            i |= i + 1 i < self.n i self.n self n self.data[i] += val self.data[i] self.data self data i val i |= i + 1 i i + 1 i 1 self self i i val val N = int(input()) N int(input()) int input() input bit = BIT(N + 1) bit BIT(N + 1) BIT N + 1 N 1 for i, c in enumerate(input()):
    ind = ord(c) - ord("a")
    bit.add(i + 1, 1 << (ind * 20)) i c enumerate(input()) enumerate input() input ind = ord(c) - ord("a") ind ord(c) - ord("a") ord(c) ord c ord("a") ord "a" bit.add(i + 1, 1 << (ind * 20)) bit.add bit add i + 1 i 1 1 << (ind * 20) 1 ind * 20 ind 20 Q = int(input()) Q int(input()) int input() input for _ in range(Q):
    parts = input().split()
    if parts[0] == "1":
        ind = int(parts[1])
        nval = 1 << ((ord(parts[2]) - ord("a")) * 20)
        val = bit.sum(ind) - bit.sum(ind - 1)
        bit.add(ind, nval - val)
    else:
        l, r = map(int, parts[1:])
        val = bit.sum(r) - bit.sum(l - 1)
        mask = (1 << 20) - 1
        ans = 0
        while val:
            if val & mask:
                ans += 1
            val >>= 20
        print(ans) _ range(Q) range Q parts = input().split() parts input().split() ().split () input split if parts[0] == "1":
        ind = int(parts[1])
        nval = 1 << ((ord(parts[2]) - ord("a")) * 20)
        val = bit.sum(ind) - bit.sum(ind - 1)
        bit.add(ind, nval - val)
    else:
        l, r = map(int, parts[1:])
        val = bit.sum(r) - bit.sum(l - 1)
        mask = (1 << 20) - 1
        ans = 0
        while val:
            if val & mask:
                ans += 1
            val >>= 20
        print(ans) parts[0] == "1" parts[0] parts 0 "1" ind = int(parts[1]) ind int(parts[1]) int parts[1] parts 1 nval = 1 << ((ord(parts[2]) - ord("a")) * 20) nval 1 << ((ord(parts[2]) - ord("a")) * 20) 1 (ord(parts[2]) - ord("a")) * 20 ord(parts[2]) - ord("a") ord(parts[2]) ord parts[2] parts 2 ord("a") ord "a" 20 val = bit.sum(ind) - bit.sum(ind - 1) val bit.sum(ind) - bit.sum(ind - 1) bit.sum(ind) bit.sum bit sum ind bit.sum(ind - 1) bit.sum bit sum ind - 1 ind 1 bit.add(ind, nval - val) bit.add bit add ind nval - val nval val l, r = map(int, parts[1:]) l map(int, parts[1:]) map int parts[1:] parts 1: 1 r val = bit.sum(r) - bit.sum(l - 1) val 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 mask = (1 << 20) - 1 mask (1 << 20) - 1 1 << 20 1 20 1 ans = 0 ans 0 while val:
            if val & mask:
                ans += 1
            val >>= 20
         val if val & mask:
                ans += 1
             val & mask val mask ans += 1 ans 1 val >>= 20 val 20 print(ans) print ans Q = int(input()) int(input()) Q mask = (1 << 20) - 1 (1 << 20) - 1 mask val >>= 20 20 val parts = input().split() input().split() parts val = bit.sum(r) - bit.sum(l - 1) bit.sum(r) - bit.sum(l - 1) val r = map(int, parts[1:]) map(int, parts[1:]) r ans += 1 1 ans N = int(input()) int(input()) N l, r = map(int, parts[1:]) map(int, parts[1:]) l ind = ord(c) - ord("a") ord(c) - ord("a") ind ind = int(parts[1]) int(parts[1]) ind nval = 1 << ((ord(parts[2]) - ord("a")) * 20) 1 << ((ord(parts[2]) - ord("a")) * 20) nval bit = BIT(N + 1) BIT(N + 1) bit val = bit.sum(ind) - bit.sum(ind - 1) bit.sum(ind) - bit.sum(ind - 1) val ans = 0 0 ans class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

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

    def add(self, i, val):
        while i < self.n:
            self.data[i] += val
            i |= i + 1 class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

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

    def add(self, i, val):
        while i < self.n:
            self.data[i] += val
            i |= i + 1 BIT
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

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

    def add(self, i, val):
        while i < self.n:
            self.data[i] += val
            i |= i + 1


N = int(input())
bit = BIT(N + 1)
for i, c in enumerate(input()):
    ind = ord(c) - ord("a")
    bit.add(i + 1, 1 << (ind * 20))
Q = int(input())
for _ in range(Q):
    parts = input().split()
    if parts[0] == "1":
        ind = int(parts[1])
        nval = 1 << ((ord(parts[2]) - ord("a")) * 20)
        val = bit.sum(ind) - bit.sum(ind - 1)
        bit.add(ind, nval - val)
    else:
        l, r = map(int, parts[1:])
        val = bit.sum(r) - bit.sum(l - 1)
        mask = (1 << 20) - 1
        ans = 0
        while val:
            if val & mask:
                ans += 1
            val >>= 20
        print(ans)
