N = int(input())
S = ["*"]*(N+1)
S[1:] = list(input())
Q = int(input())
q1,q2,q3 = [0]*Q,[0]*Q,[0]*Q
for i in range(Q):
    tmp = input().split()
    q1[i],q2[i] = map(int,tmp[:2])
    if q1[i] == 2:
        q3[i] = int(tmp[2])
    else:
        q3[i] = tmp[2]

class BIT:
    def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
    def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

    def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
    def query2(self, l, r):
        return self.query1(r) - self.query1(l)

s_pos = [BIT(N+1,[0]*(N+1)) for _ in range(26)]

for i in range(1,N+1):
    s_pos[ord(S[i]) - ord("a")].update(i,1)

alphabets = [chr(ord("a") + i) for i in range(26)]

for i in range(Q):
    if q1[i] == 1:
        s_pos[ord(S[q2[i]]) - ord("a")].update(q2[i],-1)
        S[q2[i]] = q3[i]
        s_pos[ord(q3[i]) - ord("a")].update(q2[i],1)
    else:
        ans = 0
        for c in alphabets:
            if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
        print(ans)








 N = int(input()) N int(input()) int input() input S = ["*"]*(N+1) S ["*"]*(N+1) ["*"] "*" N+1 N 1 S[1:] = list(input()) S[1:] S 1: 1 list(input()) list input() input Q = int(input()) Q int(input()) int input() input q1,q2,q3 = [0]*Q,[0]*Q,[0]*Q q1 [0]*Q [0] 0 Q q2 [0]*Q [0] 0 Q q3 [0]*Q [0] 0 Q for i in range(Q):
    tmp = input().split()
    q1[i],q2[i] = map(int,tmp[:2])
    if q1[i] == 2:
        q3[i] = int(tmp[2])
    else:
        q3[i] = tmp[2] i range(Q) range Q tmp = input().split() tmp input().split() ().split () input split q1[i],q2[i] = map(int,tmp[:2]) q1[i] q1 i map(int,tmp[:2]) map int tmp[:2] tmp :2 2 q2[i] q2 i if q1[i] == 2:
        q3[i] = int(tmp[2])
    else:
        q3[i] = tmp[2] q1[i] == 2 q1[i] q1 i 2 q3[i] = int(tmp[2]) q3[i] q3 i int(tmp[2]) int tmp[2] tmp 2 q3[i] = tmp[2] q3[i] q3 i tmp[2] tmp 2 class BIT:
    def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
    def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

    def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
    def query2(self, l, r):
        return self.query1(r) - self.query1(l) BIT def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
     __init__ self.num = n + 1 self.num self num n + 1 n 1 self.tree = [0] * self.num self.tree self tree [0] * self.num [0] 0 self.num self num for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
     i e enumerate(init_list) enumerate init_list self.update(i, e) self.update self update i e self self n n init_list init_list def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

     update k = k + 1 k k + 1 k 1 while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
         k < self.num k self.num self num self.tree[k] += x self.tree[k] self.tree self tree k x k += (k & (-k)) k k & (-k) k -k k return self self k k x x def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
     query1 ret = 0 ret 0 while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
         r > 0 r 0 ret += self.tree[r] ret self.tree[r] self.tree self tree r r -= r & (-r) r r & (-r) r -r r return ret ret self self r r def query2(self, l, r):
        return self.query1(r) - self.query1(l) query2 return self.query1(r) - self.query1(l) self.query1(r) - self.query1(l) self.query1(r) self.query1 self query1 r self.query1(l) self.query1 self query1 l self self l l r r BIT(N+1,[0]*(N+1)) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) BIT(N+1,[0]*(N+1)) BIT N+1 N 1 [0]*(N+1) [0] 0 N+1 N 1 s_pos = [BIT(N+1,[0]*(N+1)) for _ in range(26)] s_pos [BIT(N+1,[0]*(N+1)) for _ in range(26)] for i in range(1,N+1):
    s_pos[ord(S[i]) - ord("a")].update(i,1) i range(1,N+1) range 1 N+1 N 1 s_pos[ord(S[i]) - ord("a")].update(i,1) [ord(S[i]) - ord("a")].update [ord(S[i]) - ord("a")] s_pos ord(S[i]) - ord("a") ord(S[i]) ord S[i] S i ord("a") ord "a" update i 1 chr(ord("a") + i) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(ord("a") + i) chr ord("a") + i ord("a") ord "a" i alphabets = [chr(ord("a") + i) for i in range(26)] alphabets [chr(ord("a") + i) for i in range(26)] for i in range(Q):
    if q1[i] == 1:
        s_pos[ord(S[q2[i]]) - ord("a")].update(q2[i],-1)
        S[q2[i]] = q3[i]
        s_pos[ord(q3[i]) - ord("a")].update(q2[i],1)
    else:
        ans = 0
        for c in alphabets:
            if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
        print(ans) i range(Q) range Q if q1[i] == 1:
        s_pos[ord(S[q2[i]]) - ord("a")].update(q2[i],-1)
        S[q2[i]] = q3[i]
        s_pos[ord(q3[i]) - ord("a")].update(q2[i],1)
    else:
        ans = 0
        for c in alphabets:
            if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
        print(ans) q1[i] == 1 q1[i] q1 i 1 s_pos[ord(S[q2[i]]) - ord("a")].update(q2[i],-1) [ord(S[q2[i]]) - ord("a")].update [ord(S[q2[i]]) - ord("a")] s_pos ord(S[q2[i]]) - ord("a") ord(S[q2[i]]) ord S[q2[i]] S q2[i] q2 i ord("a") ord "a" update q2[i] q2 i -1 S[q2[i]] = q3[i] S[q2[i]] S q2[i] q2 i q3[i] q3 i s_pos[ord(q3[i]) - ord("a")].update(q2[i],1) [ord(q3[i]) - ord("a")].update [ord(q3[i]) - ord("a")] s_pos ord(q3[i]) - ord("a") ord(q3[i]) ord q3[i] q3 i ord("a") ord "a" update q2[i] q2 i 1 ans = 0 ans 0 for c in alphabets:
            if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
         c alphabets if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
         s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0 s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) [ord(c) - ord("a")].query2 [ord(c) - ord("a")] s_pos ord(c) - ord("a") ord(c) ord c ord("a") ord "a" query2 q2[i] q2 i q3[i]+1 q3[i] q3 i 1 0 ans += 1 ans 1 print(ans) print ans q1,q2,q3 = [0]*Q,[0]*Q,[0]*Q [0]*Q q1 ans += 1 1 ans class BIT:
    def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
    def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

    def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
    def query2(self, l, r):
        return self.query1(r) - self.query1(l) class BIT:
    def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
    def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

    def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
    def query2(self, l, r):
        return self.query1(r) - self.query1(l) BIT Q = int(input()) int(input()) Q s_pos = [BIT(N+1,[0]*(N+1)) for _ in range(26)] [BIT(N+1,[0]*(N+1)) for _ in range(26)] s_pos N = int(input()) int(input()) N ans = 0 0 ans q2,q3 = [0]*Q,[0]*Q,[0]*Q [0]*Q q2 q3 = [0]*Q,[0]*Q,[0]*Q [0]*Q q3 alphabets = [chr(ord("a") + i) for i in range(26)] [chr(ord("a") + i) for i in range(26)] alphabets S = ["*"]*(N+1) ["*"]*(N+1) S tmp = input().split() input().split() tmp
N = int(input())
S = ["*"]*(N+1)
S[1:] = list(input())
Q = int(input())
q1,q2,q3 = [0]*Q,[0]*Q,[0]*Q
for i in range(Q):
    tmp = input().split()
    q1[i],q2[i] = map(int,tmp[:2])
    if q1[i] == 2:
        q3[i] = int(tmp[2])
    else:
        q3[i] = tmp[2]

class BIT:
    def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
    def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

    def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
    def query2(self, l, r):
        return self.query1(r) - self.query1(l)

s_pos = [BIT(N+1,[0]*(N+1)) for _ in range(26)]

for i in range(1,N+1):
    s_pos[ord(S[i]) - ord("a")].update(i,1)

alphabets = [chr(ord("a") + i) for i in range(26)]

for i in range(Q):
    if q1[i] == 1:
        s_pos[ord(S[q2[i]]) - ord("a")].update(q2[i],-1)
        S[q2[i]] = q3[i]
        s_pos[ord(q3[i]) - ord("a")].update(q2[i],1)
    else:
        ans = 0
        for c in alphabets:
            if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
        print(ans)









