from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


class SegmentTree:
    
    def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

    def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

    def count(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
        return answer


def bit_count(a):
    answer = 0
    while a:
        answer += a&1
        a >>= 1
    return answer


def solve():
    ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
    N = read_int()
    S = input()
    Q = read_int()
    segment_tree = SegmentTree([1<<(ALPHABETS.index(c)) for c in S])
    for _ in range(Q):
        cmd = input().strip().split(' ')
        if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r)))


if __name__ == '__main__':
    solve() from typing import List, Any def read_int() -> int:
    return int(input().strip()) read_int return int(input().strip()) int(input().strip()) int input().strip() ().strip () input strip def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' '))) read_ints return list(map(int, input().strip().split(' '))) list(map(int, input().strip().split(' '))) list map(int, input().strip().split(' ')) map int input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' class SegmentTree:
    
    def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

    def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

    def count(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
        return answer SegmentTree def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

     __init__ self.n = len(array) self.n self n len(array) len array 0 for _ in array for _ in array _ array for _ in array 0 self.array = [0 for _ in array]+array self.array self array [0 for _ in array]+array [0 for _ in array] array for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

     i range(self.n-1, 0, -1) range self.n-1 self.n self n 1 0 -1 self.array[i] = self.array[i<<1]|self.array[i<<1|1] self.array[i] self.array self array i self.array[i<<1]|self.array[i<<1|1] self.array[i<<1] self.array self array i<<1 i 1 self.array[i<<1|1] self.array self array i<<1|1 i<<1 i 1 1 self self array array def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

     set p = self.n+i p self.n+i self.n self n i self.array[p] = v self.array[p] self.array self array p v while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

     p > 1 p 1 p >>= 1 p 1 self.array[p] = self.array[p<<1]|self.array[p<<1|1] self.array[p] self.array self array p self.array[p<<1]|self.array[p<<1|1] self.array[p<<1] self.array self array p<<1 p 1 self.array[p<<1|1] self.array self array p<<1|1 p<<1 p 1 1 self self i i v v def count(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
        return answer count l += self.n l self.n self n r += self.n r self.n self n answer = 0 answer 0 while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
         l < r l r if l&1:
                answer |= self.array[l]
                l += 1
             l&1 l 1 answer |= self.array[l] answer self.array[l] self.array self array l l += 1 l 1 if r&1:
                r -= 1
                answer |= self.array[r]
             r&1 r 1 r -= 1 r 1 answer |= self.array[r] answer self.array[r] self.array self array r l >>= 1 l 1 r >>= 1 r 1 return answer answer self self l l r r def bit_count(a):
    answer = 0
    while a:
        answer += a&1
        a >>= 1
    return answer bit_count answer = 0 answer 0 while a:
        answer += a&1
        a >>= 1
     a answer += a&1 answer a&1 a 1 a >>= 1 a 1 return answer answer a a def solve():
    ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
    N = read_int()
    S = input()
    Q = read_int()
    segment_tree = SegmentTree([1<<(ALPHABETS.index(c)) for c in S])
    for _ in range(Q):
        cmd = input().strip().split(' ')
        if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r))) solve ALPHABETS = 'abcdefghijklmnopqrstuvwxyz' ALPHABETS 'abcdefghijklmnopqrstuvwxyz' N = read_int() N read_int() read_int S = input() S input() input Q = read_int() Q read_int() read_int 1<<(ALPHABETS.index(c)) for c in S for c in S c S for c in S 1<<(ALPHABETS.index(c)) 1 ALPHABETS.index(c) ALPHABETS.index ALPHABETS index c segment_tree = SegmentTree([1<<(ALPHABETS.index(c)) for c in S]) segment_tree SegmentTree([1<<(ALPHABETS.index(c)) for c in S]) SegmentTree [1<<(ALPHABETS.index(c)) for c in S] for _ in range(Q):
        cmd = input().strip().split(' ')
        if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r))) _ range(Q) range Q cmd = input().strip().split(' ') cmd input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r))) cmd[0] == '1' cmd[0] cmd 0 '1' n = 1<<(ALPHABETS.index(cmd[2])) n 1<<(ALPHABETS.index(cmd[2])) 1 ALPHABETS.index(cmd[2]) ALPHABETS.index ALPHABETS index cmd[2] cmd 2 segment_tree.set(int(cmd[1])-1, n) segment_tree.set segment_tree set int(cmd[1])-1 int(cmd[1]) int cmd[1] cmd 1 1 n l, r = int(cmd[1])-1, int(cmd[2]) l int(cmd[1])-1 int(cmd[1]) int cmd[1] cmd 1 1 r int(cmd[2]) int cmd[2] cmd 2 print(bit_count(segment_tree.count(l, r))) print bit_count(segment_tree.count(l, r)) bit_count segment_tree.count(l, r) segment_tree.count segment_tree count l r if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve class SegmentTree:
    
    def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

    def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

    def count(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
        return answer class SegmentTree:
    
    def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

    def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

    def count(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
        return answer SegmentTree def bit_count(a):
    answer = 0
    while a:
        answer += a&1
        a >>= 1
    return answer def bit_count(a):
    answer = 0
    while a:
        answer += a&1
        a >>= 1
    return answer bit_count def read_int() -> int:
    return int(input().strip()) def read_int() -> int:
    return int(input().strip()) read_int def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' '))) def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' '))) read_ints def solve():
    ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
    N = read_int()
    S = input()
    Q = read_int()
    segment_tree = SegmentTree([1<<(ALPHABETS.index(c)) for c in S])
    for _ in range(Q):
        cmd = input().strip().split(' ')
        if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r))) def solve():
    ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
    N = read_int()
    S = input()
    Q = read_int()
    segment_tree = SegmentTree([1<<(ALPHABETS.index(c)) for c in S])
    for _ in range(Q):
        cmd = input().strip().split(' ')
        if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r))) solve
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


class SegmentTree:
    
    def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

    def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

    def count(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
        return answer


def bit_count(a):
    answer = 0
    while a:
        answer += a&1
        a >>= 1
    return answer


def solve():
    ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
    N = read_int()
    S = input()
    Q = read_int()
    segment_tree = SegmentTree([1<<(ALPHABETS.index(c)) for c in S])
    for _ in range(Q):
        cmd = input().strip().split(' ')
        if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r)))


if __name__ == '__main__':
    solve()
