import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from operator import or_


class SegmentTree:
    def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

    def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret


n = readline()
s = readline()
q = int(readline())
li = [1 << ord(x) - 97 for x in s[:-1]]
seg = SegmentTree(li, or_, 0)
ans = []
for _ in range(q):
    f, x, y = readline().split()
    x = int(x)
    if f == '1':
        seg.update(x - 1, 1 << ord(y) - 97)
    else:
        y = int(y)
        z = seg.find(x - 1, y)
        cnt = bin(z).count('1')
        ans.append(cnt)
print(*ans) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from operator import or_ class SegmentTree:
    def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

    def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret SegmentTree def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

     __init__ _len = len(orig) _len len(orig) len orig self.func = func self.func self func func self.size = 1 << (_len - 1).bit_length() self.size self size 1 << (_len - 1).bit_length() 1 (_len - 1).bit_length() _len - 1).bit_length _len - 1 _len 1 bit_length self.tree = [unit] * self.size + orig + [unit] * (self.size - _len) self.tree self tree [unit] * self.size + orig + [unit] * (self.size - _len) [unit] * self.size + orig [unit] * self.size [unit] unit self.size self size orig [unit] * (self.size - _len) [unit] unit self.size - _len self.size self size _len self.unit = unit self.unit self unit unit for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

     i range(self.size - 1, 0, -1) range self.size - 1 self.size self size 1 0 -1 self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1]) self.tree[i] self.tree self tree i func(self.tree[i * 2], self.tree[i * 2 + 1]) func self.tree[i * 2] self.tree self tree i * 2 i 2 self.tree[i * 2 + 1] self.tree self tree i * 2 + 1 i * 2 i 2 1 self self orig orig func func unit unit def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

     update i += self.size i self.size self size self.tree[i] = v self.tree[i] self.tree self tree i v while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

     i i //= 2 i 2 self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1]) self.tree[i] self.tree self tree i self.func(self.tree[i * 2], self.tree[i * 2 + 1]) self.func self func self.tree[i * 2] self.tree self tree i * 2 i 2 self.tree[i * 2 + 1] self.tree self tree i * 2 + 1 i * 2 i 2 1 self self i i v v def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret find l += self.size l self.size self size r += self.size r self.size self size ret = self.unit ret self.unit self unit while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
         l < r l r if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
             l & 1 l 1 ret = self.func(ret, self.tree[l]) ret self.func(ret, self.tree[l]) self.func self func ret self.tree[l] self.tree self tree l l += 1 l 1 if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
             r & 1 r 1 r -= 1 r 1 ret = self.func(ret, self.tree[r]) ret self.func(ret, self.tree[r]) self.func self func ret self.tree[r] self.tree self tree r l //= 2 l 2 r //= 2 r 2 return ret ret self self l l r r n = readline() n readline() readline s = readline() s readline() readline q = int(readline()) q int(readline()) int readline() readline 1 << ord(x) - 97 for x in s[:-1] for x in s[:-1] x s[:-1] s :-1 -1 for x in s[:-1] 1 << ord(x) - 97 1 ord(x) - 97 ord(x) ord x 97 li = [1 << ord(x) - 97 for x in s[:-1]] li [1 << ord(x) - 97 for x in s[:-1]] seg = SegmentTree(li, or_, 0) seg SegmentTree(li, or_, 0) SegmentTree li or_ 0 ans = [] ans [] for _ in range(q):
    f, x, y = readline().split()
    x = int(x)
    if f == '1':
        seg.update(x - 1, 1 << ord(y) - 97)
    else:
        y = int(y)
        z = seg.find(x - 1, y)
        cnt = bin(z).count('1')
        ans.append(cnt) _ range(q) range q f, x, y = readline().split() f readline().split() ().split () readline split x y x = int(x) x int(x) int x if f == '1':
        seg.update(x - 1, 1 << ord(y) - 97)
    else:
        y = int(y)
        z = seg.find(x - 1, y)
        cnt = bin(z).count('1')
        ans.append(cnt) f == '1' f '1' seg.update(x - 1, 1 << ord(y) - 97) seg.update seg update x - 1 x 1 1 << ord(y) - 97 1 ord(y) - 97 ord(y) ord y 97 y = int(y) y int(y) int y z = seg.find(x - 1, y) z seg.find(x - 1, y) seg.find seg find x - 1 x 1 y cnt = bin(z).count('1') cnt bin(z).count('1') (z).count (z) bin z count '1' ans.append(cnt) ans.append ans append cnt print(*ans) print *ans ans seg = SegmentTree(li, or_, 0) SegmentTree(li, or_, 0) seg x, y = readline().split() readline().split() x f, x, y = readline().split() readline().split() f read = sys.stdin.buffer.read sys.stdin.buffer.read read x = int(x) int(x) x y = int(y) int(y) y li = [1 << ord(x) - 97 for x in s[:-1]] [1 << ord(x) - 97 for x in s[:-1]] li ans = [] [] ans class SegmentTree:
    def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

    def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret class SegmentTree:
    def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

    def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret SegmentTree n = readline() readline() n s = readline() readline() s q = int(readline()) int(readline()) q readline = sys.stdin.readline sys.stdin.readline readline y = readline().split() readline().split() y readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines cnt = bin(z).count('1') bin(z).count('1') cnt z = seg.find(x - 1, y) seg.find(x - 1, y) z
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from operator import or_


class SegmentTree:
    def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

    def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret


n = readline()
s = readline()
q = int(readline())
li = [1 << ord(x) - 97 for x in s[:-1]]
seg = SegmentTree(li, or_, 0)
ans = []
for _ in range(q):
    f, x, y = readline().split()
    x = int(x)
    if f == '1':
        seg.update(x - 1, 1 << ord(y) - 97)
    else:
        y = int(y)
        z = seg.find(x - 1, y)
        cnt = bin(z).count('1')
        ans.append(cnt)
print(*ans)
