#https://tjkendev.github.io/procon-library/python/range_query/rmq_segment_tree.html
# N: 処理する区間の長さ

#bit管理
#演算はor
N = int(input())
s = input()


N0 = 1
while N0<=N:
    N0*=2
INF = 0
data = [0]*(2*N0)
# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = 1<<x
    while k >= 0:
        k = (k - 1) // 2
        data[k] =data[2*k+1]|data[2*k+2]
# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = s|data[R-1]

        if L & 1:
            s = s|data[L-1]
            L += 1
        L >>= 1; R >>= 1
    return s

for i in range(N):
    update(i,ord(s[i])-ord("a"))
q = int(input())

for j in range(q):
    t,l,r = input().split( )
    if t=="1":
        update(int(l)-1,ord(r)-ord("a"))
        
    else:
        bit = bin(query(int(l)-1,int(r)))[2:]
        ans = 0
        for i in bit:
            ans += int(i)
        print(ans) N = int(input()) N int(input()) int input() input s = input() s input() input N0 = 1 N0 1 while N0<=N:
    N0*=2 N0<=N N0 N N0*=2 N0 2 INF = 0 INF 0 data = [0]*(2*N0) data [0]*(2*N0) [0] 0 2*N0 2 N0 def update(k, x):
    k += N0-1
    data[k] = 1<<x
    while k >= 0:
        k = (k - 1) // 2
        data[k] =data[2*k+1]|data[2*k+2]
# 区間[l, r)の最小値 update k += N0-1 k N0-1 N0 1 data[k] = 1<<x data[k] data k 1<<x 1 x while k >= 0:
        k = (k - 1) // 2
        data[k] =data[2*k+1]|data[2*k+2]
# 区間[l, r)の最小値 k >= 0 k 0 k = (k - 1) // 2 k (k - 1) // 2 k - 1 k 1 2 data[k] =data[2*k+1]|data[2*k+2] data[k] data k data[2*k+1]|data[2*k+2] data[2*k+1] data 2*k+1 2*k 2 k 1 data[2*k+2] data 2*k+2 2*k 2 k 2 k k x x def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = s|data[R-1]

        if L & 1:
            s = s|data[L-1]
            L += 1
        L >>= 1; R >>= 1
    return s query L = l + N0 L l + N0 l N0 R = r + N0 R r + N0 r N0 s = INF s INF while L < R:
        if R & 1:
            R -= 1
            s = s|data[R-1]

        if L & 1:
            s = s|data[L-1]
            L += 1
        L >>= 1; R >>= 1
     L < R L R if R & 1:
            R -= 1
            s = s|data[R-1]

         R & 1 R 1 R -= 1 R 1 s = s|data[R-1] s s|data[R-1] s data[R-1] data R-1 R 1 if L & 1:
            s = s|data[L-1]
            L += 1
         L & 1 L 1 s = s|data[L-1] s s|data[L-1] s data[L-1] data L-1 L 1 L += 1 L 1 L >>= 1 L 1 R >>= 1 R 1 return s s l l r r for i in range(N):
    update(i,ord(s[i])-ord("a")) i range(N) range N update(i,ord(s[i])-ord("a")) update i ord(s[i])-ord("a") ord(s[i]) ord s[i] s i ord("a") ord "a" q = int(input()) q int(input()) int input() input for j in range(q):
    t,l,r = input().split( )
    if t=="1":
        update(int(l)-1,ord(r)-ord("a"))
        
    else:
        bit = bin(query(int(l)-1,int(r)))[2:]
        ans = 0
        for i in bit:
            ans += int(i)
        print(ans) j range(q) range q t,l,r = input().split( ) t input().split( ) ().split () input split l r if t=="1":
        update(int(l)-1,ord(r)-ord("a"))
        
    else:
        bit = bin(query(int(l)-1,int(r)))[2:]
        ans = 0
        for i in bit:
            ans += int(i)
        print(ans) t=="1" t "1" update(int(l)-1,ord(r)-ord("a")) update int(l)-1 int(l) int l 1 ord(r)-ord("a") ord(r) ord r ord("a") ord "a" bit = bin(query(int(l)-1,int(r)))[2:] bit bin(query(int(l)-1,int(r)))[2:] (query(int(l)-1,int(r))) bin query(int(l)-1,int(r)) query int(l)-1 int(l) int l 1 int(r) int r 2: 2 ans = 0 ans 0 for i in bit:
            ans += int(i)
         i bit ans += int(i) ans int(i) int i print(ans) print ans bit = bin(query(int(l)-1,int(r)))[2:] bin(query(int(l)-1,int(r)))[2:] bit def update(k, x):
    k += N0-1
    data[k] = 1<<x
    while k >= 0:
        k = (k - 1) // 2
        data[k] =data[2*k+1]|data[2*k+2]
# 区間[l, r)の最小値 def update(k, x):
    k += N0-1
    data[k] = 1<<x
    while k >= 0:
        k = (k - 1) // 2
        data[k] =data[2*k+1]|data[2*k+2]
# 区間[l, r)の最小値 update r = input().split( ) input().split( ) r N0 = 1 1 N0 ans += int(i) int(i) ans t,l,r = input().split( ) input().split( ) t def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = s|data[R-1]

        if L & 1:
            s = s|data[L-1]
            L += 1
        L >>= 1; R >>= 1
    return s def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = s|data[R-1]

        if L & 1:
            s = s|data[L-1]
            L += 1
        L >>= 1; R >>= 1
    return s query ans = 0 0 ans data = [0]*(2*N0) [0]*(2*N0) data l,r = input().split( ) input().split( ) l q = int(input()) int(input()) q N = int(input()) int(input()) N s = input() input() s N0*=2 2 N0 INF = 0 0 INF
#https://tjkendev.github.io/procon-library/python/range_query/rmq_segment_tree.html
# N: 処理する区間の長さ

#bit管理
#演算はor
N = int(input())
s = input()


N0 = 1
while N0<=N:
    N0*=2
INF = 0
data = [0]*(2*N0)
# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = 1<<x
    while k >= 0:
        k = (k - 1) // 2
        data[k] =data[2*k+1]|data[2*k+2]
# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = s|data[R-1]

        if L & 1:
            s = s|data[L-1]
            L += 1
        L >>= 1; R >>= 1
    return s

for i in range(N):
    update(i,ord(s[i])-ord("a"))
q = int(input())

for j in range(q):
    t,l,r = input().split( )
    if t=="1":
        update(int(l)-1,ord(r)-ord("a"))
        
    else:
        bit = bin(query(int(l)-1,int(r)))[2:]
        ans = 0
        for i in bit:
            ans += int(i)
        print(ans)