N=int(input())
S=input()
slst=[s for s in S]
Q=int(input())

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
bits=[Bit(N) for _ in range(26)]

for i in range(N):
    ch=ord(S[i])-ord('a')
    bits[ch].add(i+1,1)

for _ in range(Q):
    t,a,b=input().split()

    if t=='1':
        a=int(a)
        pos=a-1
        nextc=ord(b)-ord('a')
        beforec=ord(slst[pos])-ord('a')

        if nextc!=beforec:
            bits[beforec].add(a,-1)
            bits[nextc].add(a,1)
            slst[pos]=b
            
    else:
        l=int(a)
        r=int(b)

        cnt=[0]*26

        for i in range(26):
            cnt[i]+=bits[i].sum(r)
        
        if l-1>0:
            for i in range(26):
                cnt[i]-=bits[i].sum(l-1)
        
        ans=0

        for i in range(26):
            if cnt[i]>0:
                ans+=1
        
        print(ans) N=int(input()) N int(input()) int input() input S=input() S input() input s for s in S for s in S s S for s in S s slst=[s for s in S] slst [s for s in S] Q=int(input()) Q int(input()) int input() input class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
  Bit def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
     __init__ self.size = n self.size self size n self.tree = [0] * (n + 1) self.tree self tree [0] * (n + 1) [0] 0 n + 1 n 1 self self n n def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
     sum s = 0 s 0 while i > 0:
            s += self.tree[i]
            i -= i & -i
         i > 0 i 0 s += self.tree[i] s self.tree[i] self.tree self tree i i -= i & -i i i & -i i -i i return s s self self i i def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
  add while i <= self.size:
            self.tree[i] += x
            i += i & -i
  i <= self.size i self.size self size self.tree[i] += x self.tree[i] self.tree self tree i x i += i & -i i i & -i i -i i self self i i x x Bit(N) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) Bit(N) Bit N bits=[Bit(N) for _ in range(26)] bits [Bit(N) for _ in range(26)] for i in range(N):
    ch=ord(S[i])-ord('a')
    bits[ch].add(i+1,1) i range(N) range N ch=ord(S[i])-ord('a') ch ord(S[i])-ord('a') ord(S[i]) ord S[i] S i ord('a') ord 'a' bits[ch].add(i+1,1) [ch].add [ch] bits ch add i+1 i 1 1 for _ in range(Q):
    t,a,b=input().split()

    if t=='1':
        a=int(a)
        pos=a-1
        nextc=ord(b)-ord('a')
        beforec=ord(slst[pos])-ord('a')

        if nextc!=beforec:
            bits[beforec].add(a,-1)
            bits[nextc].add(a,1)
            slst[pos]=b
            
    else:
        l=int(a)
        r=int(b)

        cnt=[0]*26

        for i in range(26):
            cnt[i]+=bits[i].sum(r)
        
        if l-1>0:
            for i in range(26):
                cnt[i]-=bits[i].sum(l-1)
        
        ans=0

        for i in range(26):
            if cnt[i]>0:
                ans+=1
        
        print(ans) _ range(Q) range Q t,a,b=input().split() t input().split() ().split () input split a b if t=='1':
        a=int(a)
        pos=a-1
        nextc=ord(b)-ord('a')
        beforec=ord(slst[pos])-ord('a')

        if nextc!=beforec:
            bits[beforec].add(a,-1)
            bits[nextc].add(a,1)
            slst[pos]=b
            
    else:
        l=int(a)
        r=int(b)

        cnt=[0]*26

        for i in range(26):
            cnt[i]+=bits[i].sum(r)
        
        if l-1>0:
            for i in range(26):
                cnt[i]-=bits[i].sum(l-1)
        
        ans=0

        for i in range(26):
            if cnt[i]>0:
                ans+=1
        
        print(ans) t=='1' t '1' a=int(a) a int(a) int a pos=a-1 pos a-1 a 1 nextc=ord(b)-ord('a') nextc ord(b)-ord('a') ord(b) ord b ord('a') ord 'a' beforec=ord(slst[pos])-ord('a') beforec ord(slst[pos])-ord('a') ord(slst[pos]) ord slst[pos] slst pos ord('a') ord 'a' if nextc!=beforec:
            bits[beforec].add(a,-1)
            bits[nextc].add(a,1)
            slst[pos]=b
            
     nextc!=beforec nextc beforec bits[beforec].add(a,-1) [beforec].add [beforec] bits beforec add a -1 bits[nextc].add(a,1) [nextc].add [nextc] bits nextc add a 1 slst[pos]=b slst[pos] slst pos b l=int(a) l int(a) int a r=int(b) r int(b) int b cnt=[0]*26 cnt [0]*26 [0] 0 26 for i in range(26):
            cnt[i]+=bits[i].sum(r)
        
         i range(26) range 26 cnt[i]+=bits[i].sum(r) cnt[i] cnt i bits[i].sum(r) [i].sum [i] bits i sum r if l-1>0:
            for i in range(26):
                cnt[i]-=bits[i].sum(l-1)
        
         l-1>0 l-1 l 1 0 for i in range(26):
                cnt[i]-=bits[i].sum(l-1)
        
         i range(26) range 26 cnt[i]-=bits[i].sum(l-1) cnt[i] cnt i bits[i].sum(l-1) [i].sum [i] bits i sum l-1 l 1 ans=0 ans 0 for i in range(26):
            if cnt[i]>0:
                ans+=1
        
         i range(26) range 26 if cnt[i]>0:
                ans+=1
        
         cnt[i]>0 cnt[i] cnt i 0 ans+=1 ans 1 print(ans) print ans Q=int(input()) int(input()) Q r=int(b) int(b) r bits=[Bit(N) for _ in range(26)] [Bit(N) for _ in range(26)] bits ans=0 0 ans a=int(a) int(a) a ans+=1 1 ans cnt=[0]*26 [0]*26 cnt slst=[s for s in S] [s for s in S] slst ch=ord(S[i])-ord('a') ord(S[i])-ord('a') ch beforec=ord(slst[pos])-ord('a') ord(slst[pos])-ord('a') beforec pos=a-1 a-1 pos class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
  class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
  Bit t,a,b=input().split() input().split() t a,b=input().split() input().split() a b=input().split() input().split() b S=input() input() S nextc=ord(b)-ord('a') ord(b)-ord('a') nextc l=int(a) int(a) l N=int(input()) int(input()) N
N=int(input())
S=input()
slst=[s for s in S]
Q=int(input())

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
bits=[Bit(N) for _ in range(26)]

for i in range(N):
    ch=ord(S[i])-ord('a')
    bits[ch].add(i+1,1)

for _ in range(Q):
    t,a,b=input().split()

    if t=='1':
        a=int(a)
        pos=a-1
        nextc=ord(b)-ord('a')
        beforec=ord(slst[pos])-ord('a')

        if nextc!=beforec:
            bits[beforec].add(a,-1)
            bits[nextc].add(a,1)
            slst[pos]=b
            
    else:
        l=int(a)
        r=int(b)

        cnt=[0]*26

        for i in range(26):
            cnt[i]+=bits[i].sum(r)
        
        if l-1>0:
            for i in range(26):
                cnt[i]-=bits[i].sum(l-1)
        
        ans=0

        for i in range(26):
            if cnt[i]>0:
                ans+=1
        
        print(ans)
