n=int(input())+1
data=[0]*n*2
def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2
def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:]))
s=input()
for i,c in enumerate(s,n):
    data[i]=1<<(ord(c)-97)
for i in range(n-1,0,-1):
    data[i]=data[2*i]|data[2*i+1]
for _ in range(int(input())):
    q,a,b=input().split()
    if q=="2":
        print(query(int(a)-1,int(b)))
    else:
        update(int(a)-1,1<<(ord(b)-97)) n=int(input())+1 n int(input())+1 int(input()) int input() input 1 data=[0]*n*2 data [0]*n*2 [0]*n [0] 0 n 2 def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2 update i+=n i n data[i]=x data[i] data i x i//=2 i 2 while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2 i data[i]=data[i*2]|data[i*2+1] data[i] data i data[i*2]|data[i*2+1] data[i*2] data i*2 i 2 data[i*2+1] data i*2+1 i*2 i 2 1 i//=2 i 2 i i x x def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:])) query l+=n l n r+=n r n s=0 s 0 while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
     l<r l r if l&1:
            s|=data[l]
            l+=1
         l&1 l 1 s|=data[l] s data[l] data l l+=1 l 1 if r&1:
            r-=1
            s|=data[r]
         r&1 r 1 r-=1 r 1 s|=data[r] s data[r] data r l//=2 l 2 r//=2 r 2 return sum(map(int,bin(s)[2:])) sum(map(int,bin(s)[2:])) sum map(int,bin(s)[2:]) map int bin(s)[2:] (s) bin s 2: 2 l l r r s=input() s input() input for i,c in enumerate(s,n):
    data[i]=1<<(ord(c)-97) i c enumerate(s,n) enumerate s n data[i]=1<<(ord(c)-97) data[i] data i 1<<(ord(c)-97) 1 ord(c)-97 ord(c) ord c 97 for i in range(n-1,0,-1):
    data[i]=data[2*i]|data[2*i+1] i range(n-1,0,-1) range n-1 n 1 0 -1 data[i]=data[2*i]|data[2*i+1] data[i] data i data[2*i]|data[2*i+1] data[2*i] data 2*i 2 i data[2*i+1] data 2*i+1 2*i 2 i 1 for _ in range(int(input())):
    q,a,b=input().split()
    if q=="2":
        print(query(int(a)-1,int(b)))
    else:
        update(int(a)-1,1<<(ord(b)-97)) _ range(int(input())) range int(input()) int input() input q,a,b=input().split() q input().split() ().split () input split a b if q=="2":
        print(query(int(a)-1,int(b)))
    else:
        update(int(a)-1,1<<(ord(b)-97)) q=="2" q "2" print(query(int(a)-1,int(b))) print query(int(a)-1,int(b)) query int(a)-1 int(a) int a 1 int(b) int b update(int(a)-1,1<<(ord(b)-97)) update int(a)-1 int(a) int a 1 1<<(ord(b)-97) 1 ord(b)-97 ord(b) ord b 97 q,a,b=input().split() input().split() q s=input() input() s data=[0]*n*2 [0]*n*2 data def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2 def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2 update a,b=input().split() input().split() a b=input().split() input().split() b n=int(input())+1 int(input())+1 n def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:])) def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:])) query
n=int(input())+1
data=[0]*n*2
def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2
def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:]))
s=input()
for i,c in enumerate(s,n):
    data[i]=1<<(ord(c)-97)
for i in range(n-1,0,-1):
    data[i]=data[2*i]|data[2*i+1]
for _ in range(int(input())):
    q,a,b=input().split()
    if q=="2":
        print(query(int(a)-1,int(b)))
    else:
        update(int(a)-1,1<<(ord(b)-97))