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


class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

        self.ll = []
        self.rr = []
        i = self.n
        for _ in range(self.logn+1):
            for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
            i //= 2

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r, i=0):
        ll = self.ll[i]
        rr = self.rr[i]
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2))


def get_int(s):
    abc = "abcdefghijklmnopqrstuvwxyz"
    return 1 << abc.index(s)


seg = SegmentTree([get_int(i) for i in s], int.__or__, 0)

for _ in range(q):
    q, i, j = input().split()
    if q == "1":
        seg.update(int(i) - 1, get_int(j))
    else:
        aa = seg.get_segment(int(i) - 1, int(j))
        ans = 0
        for i in range(26):
            if (aa >> i) & 1 == 1:
                ans += 1
        print(ans) n = int(input()) n int(input()) int input() input s = input() s input() input q = int(input()) q int(input()) int input() input class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

        self.ll = []
        self.rr = []
        i = self.n
        for _ in range(self.logn+1):
            for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
            i //= 2

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r, i=0):
        ll = self.ll[i]
        rr = self.rr[i]
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2)) SegmentTree def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

        self.ll = []
        self.rr = []
        i = self.n
        for _ in range(self.logn+1):
            for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
            i //= 2

     __init__ self.logn = (len(a) - 1).bit_length() self.logn self logn (len(a) - 1).bit_length() len(a) - 1).bit_length len(a) - 1 len(a) len a 1 bit_length self.n = 1 << self.logn self.n self n 1 << self.logn 1 self.logn self logn self.func = func self.func self func func self.one = one self.one self one one self.b = [self.one] * (2 * self.n - 1) self.b self b [self.one] * (2 * self.n - 1) [self.one] self.one self one 2 * self.n - 1 2 * self.n 2 self.n self n 1 for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
         i j enumerate(a) enumerate a self.b[i + self.n - 1] = j self.b[i + self.n - 1] self.b self b i + self.n - 1 i + self.n i self.n self n 1 j for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

         i reversed(range(self.n - 1)) reversed range(self.n - 1) range self.n - 1 self.n self n 1 self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) self.b[i] self.b self b i self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) self.func self func self.b[i * 2 + 1] self.b self b i * 2 + 1 i * 2 i 2 1 self.b[i * 2 + 2] self.b self b i * 2 + 2 i * 2 i 2 2 self.ll = [] self.ll self ll [] self.rr = [] self.rr self rr [] i = self.n i self.n self n for _ in range(self.logn+1):
            for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
            i //= 2

     _ range(self.logn+1) range self.logn+1 self.logn self logn 1 for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
             j range(0, self.n, i) range 0 self.n self n i self.ll.append(j) self.ll.append self.ll self ll append j self.rr.append(j + i) self.rr.append self.rr self rr append j + i j i i //= 2 i 2 self self a a func=max func max one=-10 ** 18 one -10 ** 18 -10 18 def get_item(self, i):
        return self.b[i + self.n - 1]

     get_item return self.b[i + self.n - 1] self.b[i + self.n - 1] self.b self b i + self.n - 1 i + self.n i self.n self n 1 self self i i def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

     update i = index + self.n - 1 i index + self.n - 1 index + self.n index self.n self n 1 self.b[i] = x self.b[i] self.b self b i x while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

     i != 0 i 0 i = (i - 1) // 2 i (i - 1) // 2 i - 1 i 1 2 self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) self.b[i] self.b self b i self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) self.func self func self.b[i * 2 + 1] self.b self b i * 2 + 1 i * 2 i 2 1 self.b[i * 2 + 2] self.b self b i * 2 + 2 i * 2 i 2 2 self self index index x x def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

     update_func i = index + self.n - 1 i index + self.n - 1 index + self.n index self.n self n 1 self.b[i] = self.func(self.b[i], x) self.b[i] self.b self b i self.func(self.b[i], x) self.func self func self.b[i] self.b self b i x while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

     i != 0 i 0 i = (i - 1) // 2 i (i - 1) // 2 i - 1 i 1 2 self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) self.b[i] self.b self b i self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) self.func self func self.b[i * 2 + 1] self.b self b i * 2 + 1 i * 2 i 2 1 self.b[i * 2 + 2] self.b self b i * 2 + 2 i * 2 i 2 2 self self index index x x def get_segment(self, l, r, i=0):
        ll = self.ll[i]
        rr = self.rr[i]
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2)) get_segment ll = self.ll[i] ll self.ll[i] self.ll self ll i rr = self.rr[i] rr self.rr[i] self.rr self rr i if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2)) l <= ll and rr <= r l <= ll l ll rr <= r rr r return self.b[i] self.b[i] self.b self b i elif rr <= l or r <= ll:
            return self.one
         rr <= l or r <= ll rr <= l rr l r <= ll r ll return self.one self.one self one return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2)) self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2)) self.func self func self.get_segment(l, r, i * 2 + 1) self.get_segment self get_segment l r i * 2 + 1 i * 2 i 2 1 self.get_segment(l, r, i * 2 + 2) self.get_segment self get_segment l r i * 2 + 2 i * 2 i 2 2 self self l l r r i=0 i 0 def get_int(s):
    abc = "abcdefghijklmnopqrstuvwxyz"
    return 1 << abc.index(s) get_int abc = "abcdefghijklmnopqrstuvwxyz" abc "abcdefghijklmnopqrstuvwxyz" return 1 << abc.index(s) 1 << abc.index(s) 1 abc.index(s) abc.index abc index s s s get_int(i) for i in s for i in s i s for i in s get_int(i) get_int i seg = SegmentTree([get_int(i) for i in s], int.__or__, 0) seg SegmentTree([get_int(i) for i in s], int.__or__, 0) SegmentTree [get_int(i) for i in s] int.__or__ int __or__ 0 for _ in range(q):
    q, i, j = input().split()
    if q == "1":
        seg.update(int(i) - 1, get_int(j))
    else:
        aa = seg.get_segment(int(i) - 1, int(j))
        ans = 0
        for i in range(26):
            if (aa >> i) & 1 == 1:
                ans += 1
        print(ans) _ range(q) range q q, i, j = input().split() q input().split() ().split () input split i j if q == "1":
        seg.update(int(i) - 1, get_int(j))
    else:
        aa = seg.get_segment(int(i) - 1, int(j))
        ans = 0
        for i in range(26):
            if (aa >> i) & 1 == 1:
                ans += 1
        print(ans) q == "1" q "1" seg.update(int(i) - 1, get_int(j)) seg.update seg update int(i) - 1 int(i) int i 1 get_int(j) get_int j aa = seg.get_segment(int(i) - 1, int(j)) aa seg.get_segment(int(i) - 1, int(j)) seg.get_segment seg get_segment int(i) - 1 int(i) int i 1 int(j) int j ans = 0 ans 0 for i in range(26):
            if (aa >> i) & 1 == 1:
                ans += 1
         i range(26) range 26 if (aa >> i) & 1 == 1:
                ans += 1
         (aa >> i) & 1 == 1 (aa >> i) & 1 aa >> i aa i 1 1 ans += 1 ans 1 print(ans) print ans seg = SegmentTree([get_int(i) for i in s], int.__or__, 0) SegmentTree([get_int(i) for i in s], int.__or__, 0) seg aa = seg.get_segment(int(i) - 1, int(j)) seg.get_segment(int(i) - 1, int(j)) aa n = int(input()) int(input()) n ans += 1 1 ans class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

        self.ll = []
        self.rr = []
        i = self.n
        for _ in range(self.logn+1):
            for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
            i //= 2

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r, i=0):
        ll = self.ll[i]
        rr = self.rr[i]
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2)) class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

        self.ll = []
        self.rr = []
        i = self.n
        for _ in range(self.logn+1):
            for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
            i //= 2

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r, i=0):
        ll = self.ll[i]
        rr = self.rr[i]
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2)) SegmentTree i, j = input().split() input().split() i q = int(input()) int(input()) q def get_int(s):
    abc = "abcdefghijklmnopqrstuvwxyz"
    return 1 << abc.index(s) def get_int(s):
    abc = "abcdefghijklmnopqrstuvwxyz"
    return 1 << abc.index(s) get_int s = input() input() s q, i, j = input().split() input().split() q j = input().split() input().split() j ans = 0 0 ans
n = int(input())
s = input()
q = int(input())


class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

        self.ll = []
        self.rr = []
        i = self.n
        for _ in range(self.logn+1):
            for j in range(0, self.n, i):
                self.ll.append(j)
                self.rr.append(j + i)
            i //= 2

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r, i=0):
        ll = self.ll[i]
        rr = self.rr[i]
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2))


def get_int(s):
    abc = "abcdefghijklmnopqrstuvwxyz"
    return 1 << abc.index(s)


seg = SegmentTree([get_int(i) for i in s], int.__or__, 0)

for _ in range(q):
    q, i, j = input().split()
    if q == "1":
        seg.update(int(i) - 1, get_int(j))
    else:
        aa = seg.get_segment(int(i) - 1, int(j))
        ans = 0
        for i in range(26):
            if (aa >> i) & 1 == 1:
                ans += 1
        print(ans)
