import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

class SegmentTree():
    def __init__(self, init_val, N):
        """
        Parameters
        ----------
        init_val:int
            identity element
        N:int
            the number of nodes
        """
        self.init_val=init_val
        # Range Minimum Query
        self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗
        # 0-indexedで管理(N0-1からはじまる)
        self.data = [self.init_val] * (2 * self.N0)

    def _segfunc(self, left, right):
        res= left | right
        return res

    def update(self,k, x):
        """
        Parameters
        ----------
        k:int
            target index(0-index)
        x:any
            target value
        """
        k += self.N0-1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2])

    def query(self, l, r):
        """
        Parameters
        ----------
        l,r:int
            target range [l,r)

        Return
        ----------
        res:any
            val
        """
        L = l + self.N0
        R = r + self.N0
        s = self.init_val
        while L < R:
            if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
            if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

def chartobit(c):
    return 1<<(ord(c)-97)
n=inp()
s=[chartobit(i) for i in list(input()) if i!="\n"]
st = SegmentTree(0, n)
for i in range(n):
    st.update(i,s[i])
q = inp()
ans = []
for i in range(q):
    mode, first, second = input().split()
    if mode == "1":
        # if second in st.data[int(first) - 1 + st.N0 - 1]:
        #     continue
        st.update(int(first) - 1, chartobit(second))
    else:
        ans.append((st.query(int(first) - 1, int(second))))
for i in ans:
    print(sum(map(int,bin(i)[2:]))) import sys, bisect, math, itertools, heapq, collections sys bisect math itertools heapq collections from operator import itemgetter from functools import lru_cache sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline INF = float('inf') INF float('inf') float 'inf' mod = 10**9+7 mod 10**9+7 10**9 10 9 7 eps = 10**-7 eps 10**-7 10 -7 def inp():
    '''
    一つの整数
    '''
    return int(input()) inp '''
    一つの整数
    ''' return int(input()) int(input()) int input() input def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split())) inpl '''
    一行に複数の整数
    ''' return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split class SegmentTree():
    def __init__(self, init_val, N):
        """
        Parameters
        ----------
        init_val:int
            identity element
        N:int
            the number of nodes
        """
        self.init_val=init_val
        # Range Minimum Query
        self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗
        # 0-indexedで管理(N0-1からはじまる)
        self.data = [self.init_val] * (2 * self.N0)

    def _segfunc(self, left, right):
        res= left | right
        return res

    def update(self,k, x):
        """
        Parameters
        ----------
        k:int
            target index(0-index)
        x:any
            target value
        """
        k += self.N0-1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2])

    def query(self, l, r):
        """
        Parameters
        ----------
        l,r:int
            target range [l,r)

        Return
        ----------
        res:any
            val
        """
        L = l + self.N0
        R = r + self.N0
        s = self.init_val
        while L < R:
            if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
            if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s SegmentTree def __init__(self, init_val, N):
        """
        Parameters
        ----------
        init_val:int
            identity element
        N:int
            the number of nodes
        """
        self.init_val=init_val
        # Range Minimum Query
        self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗
        # 0-indexedで管理(N0-1からはじまる)
        self.data = [self.init_val] * (2 * self.N0)

     __init__ """
        Parameters
        ----------
        init_val:int
            identity element
        N:int
            the number of nodes
        """ self.init_val=init_val self.init_val self init_val init_val self.N0 = 2**(N-1).bit_length() self.N0 self N0 2**(N-1).bit_length() 2 (N-1).bit_length() N-1).bit_length N-1 N 1 bit_length self.data = [self.init_val] * (2 * self.N0) self.data self data [self.init_val] * (2 * self.N0) [self.init_val] self.init_val self init_val 2 * self.N0 2 self.N0 self N0 self self init_val init_val N N def _segfunc(self, left, right):
        res= left | right
        return res

     _segfunc res= left | right res left | right left right return res res self self left left right right def update(self,k, x):
        """
        Parameters
        ----------
        k:int
            target index(0-index)
        x:any
            target value
        """
        k += self.N0-1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2])

     update """
        Parameters
        ----------
        k:int
            target index(0-index)
        x:any
            target value
        """ k += self.N0-1 k self.N0-1 self.N0 self N0 1 self.data[k] = x self.data[k] self.data self data k x while k > 0:
            k = (k - 1) // 2
            self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2])

     k > 0 k 0 k = (k - 1) // 2 k (k - 1) // 2 k - 1 k 1 2 self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2]) self.data[k] self.data self data k self._segfunc(self.data[2*k+1], self.data[2*k+2]) self._segfunc self _segfunc self.data[2*k+1] self.data self data 2*k+1 2*k 2 k 1 self.data[2*k+2] self.data self data 2*k+2 2*k 2 k 2 self self k k x x def query(self, l, r):
        """
        Parameters
        ----------
        l,r:int
            target range [l,r)

        Return
        ----------
        res:any
            val
        """
        L = l + self.N0
        R = r + self.N0
        s = self.init_val
        while L < R:
            if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
            if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s query """
        Parameters
        ----------
        l,r:int
            target range [l,r)

        Return
        ----------
        res:any
            val
        """ L = l + self.N0 L l + self.N0 l self.N0 self N0 R = r + self.N0 R r + self.N0 r self.N0 self N0 s = self.init_val s self.init_val self init_val while L < R:
            if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
            if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
         L < R L R if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
             R & 1 R 1 R -= 1 R 1 s = self._segfunc(s, self.data[R-1]) s self._segfunc(s, self.data[R-1]) self._segfunc self _segfunc s self.data[R-1] self.data self data R-1 R 1 if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
             L & 1 L 1 s = self._segfunc(s, self.data[L-1]) s self._segfunc(s, self.data[L-1]) self._segfunc self _segfunc s self.data[L-1] self.data self data L-1 L 1 L += 1 L 1 L >>= 1 L 1 R >>= 1 R 1 return s s self self l l r r def chartobit(c):
    return 1<<(ord(c)-97) chartobit return 1<<(ord(c)-97) 1<<(ord(c)-97) 1 ord(c)-97 ord(c) ord c 97 c c n=inp() n inp() inp chartobit(i) for i in list(input()) if i!="\n" for i in list(input()) if i!="\n" i list(input()) list input() input i!="\n" i "\n" if i!="\n" chartobit(i) chartobit i s=[chartobit(i) for i in list(input()) if i!="\n"] s [chartobit(i) for i in list(input()) if i!="\n"] st = SegmentTree(0, n) st SegmentTree(0, n) SegmentTree 0 n for i in range(n):
    st.update(i,s[i]) i range(n) range n st.update(i,s[i]) st.update st update i s[i] s i q = inp() q inp() inp ans = [] ans [] for i in range(q):
    mode, first, second = input().split()
    if mode == "1":
        # if second in st.data[int(first) - 1 + st.N0 - 1]:
        #     continue
        st.update(int(first) - 1, chartobit(second))
    else:
        ans.append((st.query(int(first) - 1, int(second)))) i range(q) range q mode, first, second = input().split() mode input().split() ().split () input split first second if mode == "1":
        # if second in st.data[int(first) - 1 + st.N0 - 1]:
        #     continue
        st.update(int(first) - 1, chartobit(second))
    else:
        ans.append((st.query(int(first) - 1, int(second)))) mode == "1" mode "1" st.update(int(first) - 1, chartobit(second)) st.update st update int(first) - 1 int(first) int first 1 chartobit(second) chartobit second ans.append((st.query(int(first) - 1, int(second)))) ans.append ans append st.query(int(first) - 1, int(second)) st.query st query int(first) - 1 int(first) int first 1 int(second) int second for i in ans:
    print(sum(map(int,bin(i)[2:]))) i ans print(sum(map(int,bin(i)[2:]))) print sum(map(int,bin(i)[2:])) sum map(int,bin(i)[2:]) map int bin(i)[2:] (i) bin i 2: 2 st = SegmentTree(0, n) SegmentTree(0, n) st ans = [] [] ans n=inp() inp() n INF = float('inf') float('inf') INF second = input().split() input().split() second class SegmentTree():
    def __init__(self, init_val, N):
        """
        Parameters
        ----------
        init_val:int
            identity element
        N:int
            the number of nodes
        """
        self.init_val=init_val
        # Range Minimum Query
        self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗
        # 0-indexedで管理(N0-1からはじまる)
        self.data = [self.init_val] * (2 * self.N0)

    def _segfunc(self, left, right):
        res= left | right
        return res

    def update(self,k, x):
        """
        Parameters
        ----------
        k:int
            target index(0-index)
        x:any
            target value
        """
        k += self.N0-1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2])

    def query(self, l, r):
        """
        Parameters
        ----------
        l,r:int
            target range [l,r)

        Return
        ----------
        res:any
            val
        """
        L = l + self.N0
        R = r + self.N0
        s = self.init_val
        while L < R:
            if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
            if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s class SegmentTree():
    def __init__(self, init_val, N):
        """
        Parameters
        ----------
        init_val:int
            identity element
        N:int
            the number of nodes
        """
        self.init_val=init_val
        # Range Minimum Query
        self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗
        # 0-indexedで管理(N0-1からはじまる)
        self.data = [self.init_val] * (2 * self.N0)

    def _segfunc(self, left, right):
        res= left | right
        return res

    def update(self,k, x):
        """
        Parameters
        ----------
        k:int
            target index(0-index)
        x:any
            target value
        """
        k += self.N0-1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2])

    def query(self, l, r):
        """
        Parameters
        ----------
        l,r:int
            target range [l,r)

        Return
        ----------
        res:any
            val
        """
        L = l + self.N0
        R = r + self.N0
        s = self.init_val
        while L < R:
            if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
            if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s SegmentTree mode, first, second = input().split() input().split() mode s=[chartobit(i) for i in list(input()) if i!="\n"] [chartobit(i) for i in list(input()) if i!="\n"] s def inp():
    '''
    一つの整数
    '''
    return int(input()) def inp():
    '''
    一つの整数
    '''
    return int(input()) inp first, second = input().split() input().split() first def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split())) def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split())) inpl mod = 10**9+7 10**9+7 mod eps = 10**-7 10**-7 eps input = sys.stdin.readline sys.stdin.readline input q = inp() inp() q def chartobit(c):
    return 1<<(ord(c)-97) def chartobit(c):
    return 1<<(ord(c)-97) chartobit
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

class SegmentTree():
    def __init__(self, init_val, N):
        """
        Parameters
        ----------
        init_val:int
            identity element
        N:int
            the number of nodes
        """
        self.init_val=init_val
        # Range Minimum Query
        self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗
        # 0-indexedで管理(N0-1からはじまる)
        self.data = [self.init_val] * (2 * self.N0)

    def _segfunc(self, left, right):
        res= left | right
        return res

    def update(self,k, x):
        """
        Parameters
        ----------
        k:int
            target index(0-index)
        x:any
            target value
        """
        k += self.N0-1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2])

    def query(self, l, r):
        """
        Parameters
        ----------
        l,r:int
            target range [l,r)

        Return
        ----------
        res:any
            val
        """
        L = l + self.N0
        R = r + self.N0
        s = self.init_val
        while L < R:
            if R & 1:
                R -= 1
                s = self._segfunc(s, self.data[R-1])
    
            if L & 1:
                s = self._segfunc(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

def chartobit(c):
    return 1<<(ord(c)-97)
n=inp()
s=[chartobit(i) for i in list(input()) if i!="\n"]
st = SegmentTree(0, n)
for i in range(n):
    st.update(i,s[i])
q = inp()
ans = []
for i in range(q):
    mode, first, second = input().split()
    if mode == "1":
        # if second in st.data[int(first) - 1 + st.N0 - 1]:
        #     continue
        st.update(int(first) - 1, chartobit(second))
    else:
        ans.append((st.query(int(first) - 1, int(second))))
for i in ans:
    print(sum(map(int,bin(i)[2:])))