# セグメント木 最新バージョン
#verify
class SegTree():
    # 1-indexed
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

    def find_max_index(self, L, R, X):
        # [L,R)でX以下の物で最大indexを取得
        return self.fMi(L, R, X, 1, 0, 2**self.K)

    def find_min_index(self, L, R, X):
        # [L,R) でX以下の物で最小のindexを取得する
        return self.fmi(L, R, X, 1, 0, 2**self.K)

    def fMi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

    def fmi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r)
N = int(input())
S = list(input())
Q = int(input())
que = [tuple(input().split()) for i in range(Q)]
alpha = "abcdefghijklmnopqrstuvwxyz"
Data = {alpha[i]: [0]*N for i in range(26)}
for i in range(N):
    Data[S[i]][i] += 1
SEG = {alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26)}
for X, u, v in que:
    if X == "1":
        u = int(u)-1
        NOW = S[u]
        S[u] = v
        SEG[NOW].update(u, 0)
        SEG[v].update(u,1)
    else:
        s, t = int(u)-1, int(v)-1
        res = 0
        for j in range(26):
            res += SEG[alpha[j]].query(s, t+1)
        print(res) class SegTree():
    # 1-indexed
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

    def find_max_index(self, L, R, X):
        # [L,R)でX以下の物で最大indexを取得
        return self.fMi(L, R, X, 1, 0, 2**self.K)

    def find_min_index(self, L, R, X):
        # [L,R) でX以下の物で最小のindexを取得する
        return self.fmi(L, R, X, 1, 0, 2**self.K)

    def fMi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

    def fmi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) SegTree def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

     __init__ self.n = len(lists) self.n self n len(lists) len lists self.K = (self.n-1).bit_length() self.K self K (self.n-1).bit_length() self.n-1).bit_length self.n-1 self.n self n 1 bit_length self.f = function self.f self f function self.b = basement self.b self b basement self.seg = [basement]*(2**(self.K+1)+1) self.seg self seg [basement]*(2**(self.K+1)+1) [basement] basement 2**(self.K+1)+1 2**(self.K+1) 2 self.K+1 self.K self K 1 1 X = 2**self.K X 2**self.K 2 self.K self K for i, v in enumerate(lists):
            self.seg[i+X] = v
         i v enumerate(lists) enumerate lists self.seg[i+X] = v self.seg[i+X] self.seg self seg i+X i X v for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

     i range(X-1, 0, -1) range X-1 X 1 0 -1 self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1]) self.seg[i] self.seg self seg i self.f(self.seg[i << 1], self.seg[i << 1 | 1]) self.f self f self.seg[i << 1] self.seg self seg i << 1 i 1 self.seg[i << 1 | 1] self.seg self seg i << 1 | 1 i << 1 i 1 1 self self lists lists function function basement basement def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

     update X = 2**self.K X 2**self.K 2 self.K self K k += X k X self.seg[k] = value self.seg[k] self.seg self seg k value while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

     k k = k >> 1 k k >> 1 k 1 self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1]) self.seg[k] self.seg self seg k self.f(self.seg[k << 1], self.seg[(k << 1) | 1]) self.f self f self.seg[k << 1] self.seg self seg k << 1 k 1 self.seg[(k << 1) | 1] self.seg self seg (k << 1) | 1 k << 1 k 1 1 self self k k value value def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

     query num = 2**self.K num 2**self.K 2 self.K self K L += num L num R += num R num vL = self.b vL self.b self b vR = self.b vR self.b self b while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
         L < R L R if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
             L & 1 L 1 vL = self.f(vL, self.seg[L]) vL self.f(vL, self.seg[L]) self.f self f vL self.seg[L] self.seg self seg L L += 1 L 1 if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
             R & 1 R 1 R -= 1 R 1 vR = self.f(self.seg[R], vR) vR self.f(self.seg[R], vR) self.f self f self.seg[R] self.seg self seg R vR L >>= 1 L 1 R >>= 1 R 1 return self.f(vL, vR) self.f(vL, vR) self.f self f vL vR self self L L R R def find_max_index(self, L, R, X):
        # [L,R)でX以下の物で最大indexを取得
        return self.fMi(L, R, X, 1, 0, 2**self.K)

     find_max_index return self.fMi(L, R, X, 1, 0, 2**self.K) self.fMi(L, R, X, 1, 0, 2**self.K) self.fMi self fMi L R X 1 0 2**self.K 2 self.K self K self self L L R R X X def find_min_index(self, L, R, X):
        # [L,R) でX以下の物で最小のindexを取得する
        return self.fmi(L, R, X, 1, 0, 2**self.K)

     find_min_index return self.fmi(L, R, X, 1, 0, 2**self.K) self.fmi(L, R, X, 1, 0, 2**self.K) self.fmi self fmi L R X 1 0 2**self.K 2 self.K self K self self L L R R X X def fMi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

     fMi if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

     self.seg[k] > x or r <= a or b <= l self.seg[k] > x or r <= a self.seg[k] > x self.seg[k] self.seg self seg k x r <= a r a b <= l b l return -1 -1 if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

     k >= 2**self.K k 2**self.K 2 self.K self K return k-2**self.K k-2**self.K k 2**self.K 2 self.K self K vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r) vr self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r) self.fMi self fMi a b x (k << 1) | 1 k << 1 k 1 1 (l + r) // 2 l + r l r 2 r if vr != -1:
                    return vr
                 vr != -1 vr -1 return vr vr return self.fMi(a, b, x, k << 1, l, (l + r) // 2) self.fMi(a, b, x, k << 1, l, (l + r) // 2) self.fMi self fMi a b x k << 1 k 1 l (l + r) // 2 l + r l r 2 self self a a b b x x k k l l r r def fmi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) fmi if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) self.seg[k] > x or r <= a or b <= l self.seg[k] > x or r <= a self.seg[k] > x self.seg[k] self.seg self seg k x r <= a r a b <= l b l return -1 -1 if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) k >= 2**self.K k 2**self.K 2 self.K self K return k-2**self.K k-2**self.K k 2**self.K 2 self.K self K vl = self.fmi(a, b, x, k << 1, l, (l+r)//2) vl self.fmi(a, b, x, k << 1, l, (l+r)//2) self.fmi self fmi a b x k << 1 k 1 l (l+r)//2 l+r l r 2 if vl != -1:
                    return vl
                 vl != -1 vl -1 return vl vl return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) self.fmi self fmi a b x k << 1 | 1 k << 1 k 1 1 (l+r)//2 l+r l r 2 r self self a a b b x x k k l l r r N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input Q = int(input()) Q int(input()) int input() input tuple(input().split()) for i in range(Q) for i in range(Q) i range(Q) range Q for i in range(Q) tuple(input().split()) tuple input().split() ().split () input split que = [tuple(input().split()) for i in range(Q)] que [tuple(input().split()) for i in range(Q)] alpha = "abcdefghijklmnopqrstuvwxyz" alpha "abcdefghijklmnopqrstuvwxyz" alpha[i]: [0]*N for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) alpha[i] alpha i [0]*N [0] 0 N Data = {alpha[i]: [0]*N for i in range(26)} Data {alpha[i]: [0]*N for i in range(26)} for i in range(N):
    Data[S[i]][i] += 1 i range(N) range N Data[S[i]][i] += 1 Data[S[i]][i] [S[i]] Data S[i] S i i 1 alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) alpha[i] alpha i SegTree(Data[alpha[i]], max, 0) SegTree Data[alpha[i]] Data alpha[i] alpha i max 0 SEG = {alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26)} SEG {alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26)} for X, u, v in que:
    if X == "1":
        u = int(u)-1
        NOW = S[u]
        S[u] = v
        SEG[NOW].update(u, 0)
        SEG[v].update(u,1)
    else:
        s, t = int(u)-1, int(v)-1
        res = 0
        for j in range(26):
            res += SEG[alpha[j]].query(s, t+1)
        print(res) X u v que if X == "1":
        u = int(u)-1
        NOW = S[u]
        S[u] = v
        SEG[NOW].update(u, 0)
        SEG[v].update(u,1)
    else:
        s, t = int(u)-1, int(v)-1
        res = 0
        for j in range(26):
            res += SEG[alpha[j]].query(s, t+1)
        print(res) X == "1" X "1" u = int(u)-1 u int(u)-1 int(u) int u 1 NOW = S[u] NOW S[u] S u S[u] = v S[u] S u v SEG[NOW].update(u, 0) [NOW].update [NOW] SEG NOW update u 0 SEG[v].update(u,1) [v].update [v] SEG v update u 1 s, t = int(u)-1, int(v)-1 s int(u)-1 int(u) int u 1 t int(v)-1 int(v) int v 1 res = 0 res 0 for j in range(26):
            res += SEG[alpha[j]].query(s, t+1)
         j range(26) range 26 res += SEG[alpha[j]].query(s, t+1) res SEG[alpha[j]].query(s, t+1) [alpha[j]].query [alpha[j]] SEG alpha[j] alpha j query s t+1 t 1 print(res) print res s, t = int(u)-1, int(v)-1 int(u)-1 s SEG = {alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26)} {alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26)} SEG res = 0 0 res res += SEG[alpha[j]].query(s, t+1) SEG[alpha[j]].query(s, t+1) res S = list(input()) list(input()) S alpha = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" alpha NOW = S[u] S[u] NOW Q = int(input()) int(input()) Q u = int(u)-1 int(u)-1 u class SegTree():
    # 1-indexed
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

    def find_max_index(self, L, R, X):
        # [L,R)でX以下の物で最大indexを取得
        return self.fMi(L, R, X, 1, 0, 2**self.K)

    def find_min_index(self, L, R, X):
        # [L,R) でX以下の物で最小のindexを取得する
        return self.fmi(L, R, X, 1, 0, 2**self.K)

    def fMi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

    def fmi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) class SegTree():
    # 1-indexed
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

    def find_max_index(self, L, R, X):
        # [L,R)でX以下の物で最大indexを取得
        return self.fMi(L, R, X, 1, 0, 2**self.K)

    def find_min_index(self, L, R, X):
        # [L,R) でX以下の物で最小のindexを取得する
        return self.fmi(L, R, X, 1, 0, 2**self.K)

    def fMi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

    def fmi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r) SegTree N = int(input()) int(input()) N t = int(u)-1, int(v)-1 int(v)-1 t que = [tuple(input().split()) for i in range(Q)] [tuple(input().split()) for i in range(Q)] que Data = {alpha[i]: [0]*N for i in range(26)} {alpha[i]: [0]*N for i in range(26)} Data
# セグメント木 最新バージョン
#verify
class SegTree():
    # 1-indexed
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

    def find_max_index(self, L, R, X):
        # [L,R)でX以下の物で最大indexを取得
        return self.fMi(L, R, X, 1, 0, 2**self.K)

    def find_min_index(self, L, R, X):
        # [L,R) でX以下の物で最小のindexを取得する
        return self.fmi(L, R, X, 1, 0, 2**self.K)

    def fMi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

    def fmi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r)
N = int(input())
S = list(input())
Q = int(input())
que = [tuple(input().split()) for i in range(Q)]
alpha = "abcdefghijklmnopqrstuvwxyz"
Data = {alpha[i]: [0]*N for i in range(26)}
for i in range(N):
    Data[S[i]][i] += 1
SEG = {alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26)}
for X, u, v in que:
    if X == "1":
        u = int(u)-1
        NOW = S[u]
        S[u] = v
        SEG[NOW].update(u, 0)
        SEG[v].update(u,1)
    else:
        s, t = int(u)-1, int(v)-1
        res = 0
        for j in range(26):
            res += SEG[alpha[j]].query(s, t+1)
        print(res)
