def segfunc(x,y):
    return x|y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
n=int(input())
S=input()
Q=int(input())

num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
alphabet={key:alphabetlist.index(key)  for key in alphabetlist}

data=[0 for i in range(0,n)]
for i in range(0,n):
    data[i]=2**(alphabet[S[i]])

init(data)

ans=[]
for i in range(0,Q):
    q,a,b=input().split()
    if q=='1':
        update(int(a)-1,2**(alphabet[b]))
    else:
        a=int(a)
        b=int(b)
        ans.append(query(a-1,b))

for i in range(len(ans)):
    x=ans[i]
    print(bin(x).count('1')) def segfunc(x,y):
    return x|y segfunc return x|y x|y x y x x y y def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) init for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
     i range(n) range n seg[i+num-1]=init_val[i] seg[i+num-1] seg i+num-1 i+num i num 1 init_val[i] init_val i for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) i range(num-2,-1,-1) range num-2 num 2 -1 -1 seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) seg[i] seg i segfunc(seg[2*i+1],seg[2*i+2]) segfunc seg[2*i+1] seg 2*i+1 2*i 2 i 1 seg[2*i+2] seg 2*i+2 2*i 2 i 2 init_val init_val def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) update k += num-1 k num-1 num 1 seg[k] = x seg[k] seg k x while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) k k = (k-1)//2 k (k-1)//2 k-1 k 1 2 seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) seg[k] seg k segfunc(seg[k*2+1],seg[k*2+2]) segfunc seg[k*2+1] seg k*2+1 k*2 k 2 1 seg[k*2+2] seg k*2+2 k*2 k 2 2 k k x x def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元###### query if q<=p:
        return ide_ele
     q<=p q p return ide_ele ide_ele p += num-1 p num-1 num 1 q += num-2 q num-2 num 2 res=ide_ele res ide_ele while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
     q-p>1 q-p q p 1 if p&1 == 0:
            res = segfunc(res,seg[p])
         p&1 == 0 p&1 p 1 0 res = segfunc(res,seg[p]) res segfunc(res,seg[p]) segfunc res seg[p] seg p if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
         q&1 == 1 q&1 q 1 1 res = segfunc(res,seg[q]) res segfunc(res,seg[q]) segfunc res seg[q] seg q q -= 1 q 1 p = p//2 p p//2 p 2 q = (q-1)//2 q (q-1)//2 q-1 q 1 2 if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
     p == q p q res = segfunc(res,seg[p]) res segfunc(res,seg[p]) segfunc res seg[p] seg p res = segfunc(segfunc(res,seg[p]),seg[q]) res segfunc(segfunc(res,seg[p]),seg[q]) segfunc segfunc(res,seg[p]) segfunc res seg[p] seg p seg[q] seg q return res res p p q q ide_ele = 0 ide_ele 0 n=int(input()) n int(input()) int input() input S=input() S input() input Q=int(input()) Q int(input()) int input() input num =2**(n-1).bit_length() num 2**(n-1).bit_length() 2 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length seg=[ide_ele]*2*num seg [ide_ele]*2*num [ide_ele]*2 [ide_ele] ide_ele 2 num alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] alphabetlist ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' key:alphabetlist.index(key)  for key in alphabetlist for key in alphabetlist key alphabetlist for key in alphabetlist key alphabetlist.index(key) alphabetlist.index alphabetlist index key alphabet={key:alphabetlist.index(key)  for key in alphabetlist} alphabet {key:alphabetlist.index(key)  for key in alphabetlist} 0 for i in range(0,n) for i in range(0,n) i range(0,n) range 0 n for i in range(0,n) 0 data=[0 for i in range(0,n)] data [0 for i in range(0,n)] for i in range(0,n):
    data[i]=2**(alphabet[S[i]]) i range(0,n) range 0 n data[i]=2**(alphabet[S[i]]) data[i] data i 2**(alphabet[S[i]]) 2 alphabet[S[i]] alphabet S[i] S i init(data) init data ans=[] ans [] for i in range(0,Q):
    q,a,b=input().split()
    if q=='1':
        update(int(a)-1,2**(alphabet[b]))
    else:
        a=int(a)
        b=int(b)
        ans.append(query(a-1,b)) i range(0,Q) range 0 Q q,a,b=input().split() q input().split() ().split () input split a b if q=='1':
        update(int(a)-1,2**(alphabet[b]))
    else:
        a=int(a)
        b=int(b)
        ans.append(query(a-1,b)) q=='1' q '1' update(int(a)-1,2**(alphabet[b])) update int(a)-1 int(a) int a 1 2**(alphabet[b]) 2 alphabet[b] alphabet b a=int(a) a int(a) int a b=int(b) b int(b) int b ans.append(query(a-1,b)) ans.append ans append query(a-1,b) query a-1 a 1 b for i in range(len(ans)):
    x=ans[i]
    print(bin(x).count('1')) i range(len(ans)) range len(ans) len ans x=ans[i] x ans[i] ans i print(bin(x).count('1')) print bin(x).count('1') (x).count (x) bin x count '1' alphabet={key:alphabetlist.index(key)  for key in alphabetlist} {key:alphabetlist.index(key)  for key in alphabetlist} alphabet ide_ele = 0 0 ide_ele q,a,b=input().split() input().split() q b=int(b) int(b) b Q=int(input()) int(input()) Q seg=[ide_ele]*2*num [ide_ele]*2*num seg a=int(a) int(a) a n=int(input()) int(input()) n def segfunc(x,y):
    return x|y def segfunc(x,y):
    return x|y segfunc num =2**(n-1).bit_length() 2**(n-1).bit_length() num def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元###### def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元###### query ans=[] [] ans def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) update def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) init S=input() input() S x=ans[i] ans[i] x data=[0 for i in range(0,n)] [0 for i in range(0,n)] data b=input().split() input().split() b a,b=input().split() input().split() a alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] alphabetlist
def segfunc(x,y):
    return x|y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
n=int(input())
S=input()
Q=int(input())

num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
alphabet={key:alphabetlist.index(key)  for key in alphabetlist}

data=[0 for i in range(0,n)]
for i in range(0,n):
    data[i]=2**(alphabet[S[i]])

init(data)

ans=[]
for i in range(0,Q):
    q,a,b=input().split()
    if q=='1':
        update(int(a)-1,2**(alphabet[b]))
    else:
        a=int(a)
        b=int(b)
        ans.append(query(a-1,b))

for i in range(len(ans)):
    x=ans[i]
    print(bin(x).count('1'))
