N = int(input())
S = input()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr)
bits = [BinaryIndexedTree(N) for i in range(26)]

s = []
for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)
    s.append(c)

ans = []
for a,b,c in qs:
    if a=='1':
        i = int(b)-1
        bits[ctoi(s[i])].add(i,-1)
        bits[ctoi(c)].add(i,1)
        s[i] = c
    else:
        l,r = int(b)-1,int(c)
        a = 0
        for i in range(26):
            if bits[i].sum(l,r):
                a += 1
        ans.append(a)
print(*ans,sep='\n') N = int(input()) N int(input()) int input() input S = input() S input() input Q = int(input()) Q int(input()) int input() input input().split() for i in range(Q) for i in range(Q) i range(Q) range Q for i in range(Q) input().split() ().split () input split qs = [input().split() for i in range(Q)] qs [input().split() for i in range(Q)] def ctoi(c):
    return ord(c) - ord('a') ctoi return ord(c) - ord('a') ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' c c class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr) BinaryIndexedTree def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
     __init__ self.N = size self.N self N size self.bit = [0]*(size+1) self.bit self bit [0]*(size+1) [0] 0 size+1 size 1 self self size size def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
     add x += 1 x 1 while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
     x <= self.N x self.N self N self.bit[x] += w self.bit[x] self.bit self bit x w x += (x & -x) x x & -x x -x x self self x x w w def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
     _sum ret = 0 ret 0 while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
         x > 0 x 0 ret += self.bit[x] ret self.bit[x] self.bit self bit x x -= (x & -x) x x & -x x -x x return ret ret self self x x def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
     sum return self._sum(r) - self._sum(l) self._sum(r) - self._sum(l) self._sum(r) self._sum self _sum r self._sum(l) self._sum self _sum l self self l l r r def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr) __str__ self.sum(i,i+1) for i in range(self.N) for i in range(self.N) i range(self.N) range self.N self N for i in range(self.N) self.sum(i,i+1) self.sum self sum i i+1 i 1 arr = [self.sum(i,i+1) for i in range(self.N)] arr [self.sum(i,i+1) for i in range(self.N)] return str(arr) str(arr) str arr self self BinaryIndexedTree(N) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) BinaryIndexedTree(N) BinaryIndexedTree N bits = [BinaryIndexedTree(N) for i in range(26)] bits [BinaryIndexedTree(N) for i in range(26)] s = [] s [] for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)
    s.append(c) i c enumerate(S) enumerate S bits[ctoi(c)].add(i,1) [ctoi(c)].add [ctoi(c)] bits ctoi(c) ctoi c add i 1 s.append(c) s.append s append c ans = [] ans [] for a,b,c in qs:
    if a=='1':
        i = int(b)-1
        bits[ctoi(s[i])].add(i,-1)
        bits[ctoi(c)].add(i,1)
        s[i] = c
    else:
        l,r = int(b)-1,int(c)
        a = 0
        for i in range(26):
            if bits[i].sum(l,r):
                a += 1
        ans.append(a) a b c qs if a=='1':
        i = int(b)-1
        bits[ctoi(s[i])].add(i,-1)
        bits[ctoi(c)].add(i,1)
        s[i] = c
    else:
        l,r = int(b)-1,int(c)
        a = 0
        for i in range(26):
            if bits[i].sum(l,r):
                a += 1
        ans.append(a) a=='1' a '1' i = int(b)-1 i int(b)-1 int(b) int b 1 bits[ctoi(s[i])].add(i,-1) [ctoi(s[i])].add [ctoi(s[i])] bits ctoi(s[i]) ctoi s[i] s i add i -1 bits[ctoi(c)].add(i,1) [ctoi(c)].add [ctoi(c)] bits ctoi(c) ctoi c add i 1 s[i] = c s[i] s i c l,r = int(b)-1,int(c) l int(b)-1 int(b) int b 1 r int(c) int c a = 0 a 0 for i in range(26):
            if bits[i].sum(l,r):
                a += 1
         i range(26) range 26 if bits[i].sum(l,r):
                a += 1
         bits[i].sum(l,r) [i].sum [i] bits i sum l r a += 1 a 1 ans.append(a) ans.append ans append a print(*ans,sep='\n') print *ans ans sep='\n' sep '\n' s = [] [] s i = int(b)-1 int(b)-1 i qs = [input().split() for i in range(Q)] [input().split() for i in range(Q)] qs a += 1 1 a r = int(b)-1,int(c) int(c) r S = input() input() S def ctoi(c):
    return ord(c) - ord('a') def ctoi(c):
    return ord(c) - ord('a') ctoi class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr) class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr) BinaryIndexedTree N = int(input()) int(input()) N Q = int(input()) int(input()) Q ans = [] [] ans bits = [BinaryIndexedTree(N) for i in range(26)] [BinaryIndexedTree(N) for i in range(26)] bits l,r = int(b)-1,int(c) int(b)-1 l a = 0 0 a
N = int(input())
S = input()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr)
bits = [BinaryIndexedTree(N) for i in range(26)]

s = []
for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)
    s.append(c)

ans = []
for a,b,c in qs:
    if a=='1':
        i = int(b)-1
        bits[ctoi(s[i])].add(i,-1)
        bits[ctoi(c)].add(i,1)
        s[i] = c
    else:
        l,r = int(b)-1,int(c)
        a = 0
        for i in range(26):
            if bits[i].sum(l,r):
                a += 1
        ans.append(a)
print(*ans,sep='\n')