def update(i,x):
    i += d-1
    bit = ord(x)-97
    seg[i] = 0 | (1<<bit)
    while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2]
def find(a,b,k,l,r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return seg[k]
    c1 = find(a,b,2*k+1,l,(l+r)//2)
    c2 = find(a,b,2*k+2,(l+r)//2,r)
    return c1|c2
n = int(input())
s = input()
q = int(input())
d = 1
while d < n:
    d *= 2
seg = [0]*(2*d-1)
for i in range(n):
    update(i,s[i])
for i in range(q):
    type,a,b = input().split()
    if type == "1":
        update(int(a)-1,b)
    else:
        part = find(int(a)-1,int(b),0,0,d)
        print(bin(part).count("1")) def update(i,x):
    i += d-1
    bit = ord(x)-97
    seg[i] = 0 | (1<<bit)
    while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2] update i += d-1 i d-1 d 1 bit = ord(x)-97 bit ord(x)-97 ord(x) ord x 97 seg[i] = 0 | (1<<bit) seg[i] seg i 0 | (1<<bit) 0 1<<bit 1 bit while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2] i > 0 i 0 i = (i-1)//2 i (i-1)//2 i-1 i 1 2 seg[i] = seg[i*2+1]|seg[i*2+2] seg[i] seg i seg[i*2+1]|seg[i*2+2] seg[i*2+1] seg i*2+1 i*2 i 2 1 seg[i*2+2] seg i*2+2 i*2 i 2 2 i i x x def find(a,b,k,l,r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return seg[k]
    c1 = find(a,b,2*k+1,l,(l+r)//2)
    c2 = find(a,b,2*k+2,(l+r)//2,r)
    return c1|c2 find if r <= a or b <= l:
        return 0
     r <= a or b <= l r <= a r a b <= l b l return 0 0 if a <= l and r <= b:
        return seg[k]
     a <= l and r <= b a <= l a l r <= b r b return seg[k] seg[k] seg k c1 = find(a,b,2*k+1,l,(l+r)//2) c1 find(a,b,2*k+1,l,(l+r)//2) find a b 2*k+1 2*k 2 k 1 l (l+r)//2 l+r l r 2 c2 = find(a,b,2*k+2,(l+r)//2,r) c2 find(a,b,2*k+2,(l+r)//2,r) find a b 2*k+2 2*k 2 k 2 (l+r)//2 l+r l r 2 r return c1|c2 c1|c2 c1 c2 a a b b k k l l r r n = int(input()) n int(input()) int input() input s = input() s input() input q = int(input()) q int(input()) int input() input d = 1 d 1 while d < n:
    d *= 2 d < n d n d *= 2 d 2 seg = [0]*(2*d-1) seg [0]*(2*d-1) [0] 0 2*d-1 2*d 2 d 1 for i in range(n):
    update(i,s[i]) i range(n) range n update(i,s[i]) update i s[i] s i for i in range(q):
    type,a,b = input().split()
    if type == "1":
        update(int(a)-1,b)
    else:
        part = find(int(a)-1,int(b),0,0,d)
        print(bin(part).count("1")) i range(q) range q type,a,b = input().split() type input().split() ().split () input split a b if type == "1":
        update(int(a)-1,b)
    else:
        part = find(int(a)-1,int(b),0,0,d)
        print(bin(part).count("1")) type == "1" type "1" update(int(a)-1,b) update int(a)-1 int(a) int a 1 b part = find(int(a)-1,int(b),0,0,d) part find(int(a)-1,int(b),0,0,d) find int(a)-1 int(a) int a 1 int(b) int b 0 0 d print(bin(part).count("1")) print bin(part).count("1") (part).count (part) bin part count "1" part = find(int(a)-1,int(b),0,0,d) find(int(a)-1,int(b),0,0,d) part d *= 2 2 d seg = [0]*(2*d-1) [0]*(2*d-1) seg d = 1 1 d b = input().split() input().split() b a,b = input().split() input().split() a type,a,b = input().split() input().split() type n = int(input()) int(input()) n def find(a,b,k,l,r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return seg[k]
    c1 = find(a,b,2*k+1,l,(l+r)//2)
    c2 = find(a,b,2*k+2,(l+r)//2,r)
    return c1|c2 def find(a,b,k,l,r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return seg[k]
    c1 = find(a,b,2*k+1,l,(l+r)//2)
    c2 = find(a,b,2*k+2,(l+r)//2,r)
    return c1|c2 find s = input() input() s def update(i,x):
    i += d-1
    bit = ord(x)-97
    seg[i] = 0 | (1<<bit)
    while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2] def update(i,x):
    i += d-1
    bit = ord(x)-97
    seg[i] = 0 | (1<<bit)
    while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2] update q = int(input()) int(input()) q
def update(i,x):
    i += d-1
    bit = ord(x)-97
    seg[i] = 0 | (1<<bit)
    while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2]
def find(a,b,k,l,r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return seg[k]
    c1 = find(a,b,2*k+1,l,(l+r)//2)
    c2 = find(a,b,2*k+2,(l+r)//2,r)
    return c1|c2
n = int(input())
s = input()
q = int(input())
d = 1
while d < n:
    d *= 2
seg = [0]*(2*d-1)
for i in range(n):
    update(i,s[i])
for i in range(q):
    type,a,b = input().split()
    if type == "1":
        update(int(a)-1,b)
    else:
        part = find(int(a)-1,int(b),0,0,d)
        print(bin(part).count("1"))
