import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

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+1) for i in range(26)]
for i,c in enumerate(S):
    ci = ord(c) - ord('a')
    bits[ci].add(i,1)
now = list(S)

for a,b,c in qs:
    if a=='1':
        b = int(b)
        pi = ord(now[b-1]) - ord('a')
        bits[pi].add(b-1, -1)
        ci = ord(c) - ord('a')
        bits[ci].add(b-1, 1)
        now[b-1] = c
    else:
        b,c = int(b),int(c)
        cnt = 0
        for i in range(26):
            cnt += int(bits[i].sum(b-1,c) > 0)
        print(cnt) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input S = input().rstrip() S input().rstrip() ().rstrip () input rstrip 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)] 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+1) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) BinaryIndexedTree(N+1) BinaryIndexedTree N+1 N 1 bits = [BinaryIndexedTree(N+1) for i in range(26)] bits [BinaryIndexedTree(N+1) for i in range(26)] for i,c in enumerate(S):
    ci = ord(c) - ord('a')
    bits[ci].add(i,1) i c enumerate(S) enumerate S ci = ord(c) - ord('a') ci ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' bits[ci].add(i,1) [ci].add [ci] bits ci add i 1 now = list(S) now list(S) list S for a,b,c in qs:
    if a=='1':
        b = int(b)
        pi = ord(now[b-1]) - ord('a')
        bits[pi].add(b-1, -1)
        ci = ord(c) - ord('a')
        bits[ci].add(b-1, 1)
        now[b-1] = c
    else:
        b,c = int(b),int(c)
        cnt = 0
        for i in range(26):
            cnt += int(bits[i].sum(b-1,c) > 0)
        print(cnt) a b c qs if a=='1':
        b = int(b)
        pi = ord(now[b-1]) - ord('a')
        bits[pi].add(b-1, -1)
        ci = ord(c) - ord('a')
        bits[ci].add(b-1, 1)
        now[b-1] = c
    else:
        b,c = int(b),int(c)
        cnt = 0
        for i in range(26):
            cnt += int(bits[i].sum(b-1,c) > 0)
        print(cnt) a=='1' a '1' b = int(b) b int(b) int b pi = ord(now[b-1]) - ord('a') pi ord(now[b-1]) - ord('a') ord(now[b-1]) ord now[b-1] now b-1 b 1 ord('a') ord 'a' bits[pi].add(b-1, -1) [pi].add [pi] bits pi add b-1 b 1 -1 ci = ord(c) - ord('a') ci ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' bits[ci].add(b-1, 1) [ci].add [ci] bits ci add b-1 b 1 1 now[b-1] = c now[b-1] now b-1 b 1 c b,c = int(b),int(c) b int(b) int b c int(c) int c cnt = 0 cnt 0 for i in range(26):
            cnt += int(bits[i].sum(b-1,c) > 0)
         i range(26) range 26 cnt += int(bits[i].sum(b-1,c) > 0) cnt int(bits[i].sum(b-1,c) > 0) int bits[i].sum(b-1,c) > 0 bits[i].sum(b-1,c) [i].sum [i] bits i sum b-1 b 1 c 0 print(cnt) print cnt cnt = 0 0 cnt bits = [BinaryIndexedTree(N+1) for i in range(26)] [BinaryIndexedTree(N+1) for i in range(26)] bits input = sys.stdin.readline sys.stdin.readline input ci = ord(c) - ord('a') ord(c) - ord('a') ci b,c = int(b),int(c) int(b) b cnt += int(bits[i].sum(b-1,c) > 0) int(bits[i].sum(b-1,c) > 0) cnt qs = [input().split() for i in range(Q)] [input().split() for i in range(Q)] qs Q = int(input()) int(input()) Q ci = ord(c) - ord('a') ord(c) - ord('a') ci pi = ord(now[b-1]) - ord('a') ord(now[b-1]) - ord('a') pi N = int(input()) int(input()) N 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 S = input().rstrip() input().rstrip() S now = list(S) list(S) now b = int(b) int(b) b c = int(b),int(c) int(c) c
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

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+1) for i in range(26)]
for i,c in enumerate(S):
    ci = ord(c) - ord('a')
    bits[ci].add(i,1)
now = list(S)

for a,b,c in qs:
    if a=='1':
        b = int(b)
        pi = ord(now[b-1]) - ord('a')
        bits[pi].add(b-1, -1)
        ci = ord(c) - ord('a')
        bits[ci].add(b-1, 1)
        now[b-1] = c
    else:
        b,c = int(b),int(c)
        cnt = 0
        for i in range(26):
            cnt += int(bits[i].sum(b-1,c) > 0)
        print(cnt)