class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

ide_ele=0

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

def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f

import sys

input=sys.stdin.readline

N=int(input())
S=input().rstrip()

init_val=[1<<(ord(S[i])-97) for i in range(N)]
test=SegTree(init_val,segfunc,ide_ele)

for _ in range(int(input())):
    t,l,r=input().split()
    t,l=int(t),int(l)
    if t==1:
        val=ord(r)-97
        test.update(l-1,1<<val)
    else:
        r=int(r)
        res=test.query(l-1,r)
        print(popcount(res)) class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res SegTree def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

     __init__ n = len(init_val) n len(init_val) len init_val self.segfunc = segfunc self.segfunc self segfunc segfunc self.ide_ele = ide_ele self.ide_ele self ide_ele ide_ele self.num = 1 << (n - 1).bit_length() self.num self num 1 << (n - 1).bit_length() 1 (n - 1).bit_length() n - 1).bit_length n - 1 n 1 bit_length self.tree = [ide_ele] * 2 * self.num self.tree self tree [ide_ele] * 2 * self.num [ide_ele] * 2 [ide_ele] ide_ele 2 self.num self num for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
         i range(n) range n self.tree[self.num + i] = init_val[i] self.tree[self.num + i] self.tree self tree self.num + i self.num self num i init_val[i] init_val i for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

     i range(self.num - 1, 0, -1) range self.num - 1 self.num self num 1 0 -1 self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) self.tree[i] self.tree self tree i self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) self.segfunc self segfunc self.tree[2 * i] self.tree self tree 2 * i 2 i self.tree[2 * i + 1] self.tree self tree 2 * i + 1 2 * i 2 i 1 self self init_val init_val segfunc segfunc ide_ele ide_ele def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

     update k += self.num k self.num self num self.tree[k] = x self.tree[k] self.tree self tree k x while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

     k > 1 k 1 self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) self.tree[k >> 1] self.tree self tree k >> 1 k 1 self.segfunc(self.tree[k], self.tree[k ^ 1]) self.segfunc self segfunc self.tree[k] self.tree self tree k self.tree[k ^ 1] self.tree self tree k ^ 1 k 1 k >>= 1 k 1 self self k k x x def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res query res = self.ide_ele res self.ide_ele self ide_ele l += self.num l self.num self num r += self.num r self.num self num while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
         l < r l r if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
             l & 1 l 1 res = self.segfunc(res, self.tree[l]) res self.segfunc(res, self.tree[l]) self.segfunc self segfunc res self.tree[l] self.tree self tree l l += 1 l 1 if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
             r & 1 r 1 res = self.segfunc(res, self.tree[r - 1]) res self.segfunc(res, self.tree[r - 1]) self.segfunc self segfunc res self.tree[r - 1] self.tree self tree r - 1 r 1 l >>= 1 l 1 r >>= 1 r 1 return res res self self l l r r ide_ele=0 ide_ele 0 def segfunc(x,y):
    return x|y segfunc return x|y x|y x y x x y y def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f popcount x = x - ((x >> 1) & 0x55555555) x x - ((x >> 1) & 0x55555555) x (x >> 1) & 0x55555555 x >> 1 x 1 0x55555555 x = (x & 0x33333333) + ((x >> 2) & 0x33333333) x (x & 0x33333333) + ((x >> 2) & 0x33333333) x & 0x33333333 x 0x33333333 (x >> 2) & 0x33333333 x >> 2 x 2 0x33333333 x = (x + (x >> 4)) & 0x0f0f0f0f x (x + (x >> 4)) & 0x0f0f0f0f x + (x >> 4) x x >> 4 x 4 0x0f0f0f0f x = x + (x >> 8) x x + (x >> 8) x x >> 8 x 8 x = x + (x >> 16) x x + (x >> 16) x x >> 16 x 16 return x & 0x0000007f x & 0x0000007f x 0x0000007f x x import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N=int(input()) N int(input()) int input() input S=input().rstrip() S input().rstrip() ().rstrip () input rstrip 1<<(ord(S[i])-97) for i in range(N) for i in range(N) i range(N) range N for i in range(N) 1<<(ord(S[i])-97) 1 ord(S[i])-97 ord(S[i]) ord S[i] S i 97 init_val=[1<<(ord(S[i])-97) for i in range(N)] init_val [1<<(ord(S[i])-97) for i in range(N)] test=SegTree(init_val,segfunc,ide_ele) test SegTree(init_val,segfunc,ide_ele) SegTree init_val segfunc ide_ele for _ in range(int(input())):
    t,l,r=input().split()
    t,l=int(t),int(l)
    if t==1:
        val=ord(r)-97
        test.update(l-1,1<<val)
    else:
        r=int(r)
        res=test.query(l-1,r)
        print(popcount(res)) _ range(int(input())) range int(input()) int input() input t,l,r=input().split() t input().split() ().split () input split l r t,l=int(t),int(l) t int(t) int t l int(l) int l if t==1:
        val=ord(r)-97
        test.update(l-1,1<<val)
    else:
        r=int(r)
        res=test.query(l-1,r)
        print(popcount(res)) t==1 t 1 val=ord(r)-97 val ord(r)-97 ord(r) ord r 97 test.update(l-1,1<<val) test.update test update l-1 l 1 1<<val 1 val r=int(r) r int(r) int r res=test.query(l-1,r) res test.query(l-1,r) test.query test query l-1 l 1 r print(popcount(res)) print popcount(res) popcount res l,r=input().split() input().split() l l=int(t),int(l) int(l) l def segfunc(x,y):
    return x|y def segfunc(x,y):
    return x|y segfunc input=sys.stdin.readline sys.stdin.readline input t,l,r=input().split() input().split() t init_val=[1<<(ord(S[i])-97) for i in range(N)] [1<<(ord(S[i])-97) for i in range(N)] init_val res=test.query(l-1,r) test.query(l-1,r) res ide_ele=0 0 ide_ele class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res SegTree r=int(r) int(r) r S=input().rstrip() input().rstrip() S test=SegTree(init_val,segfunc,ide_ele) SegTree(init_val,segfunc,ide_ele) test def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f popcount N=int(input()) int(input()) N r=input().split() input().split() r val=ord(r)-97 ord(r)-97 val t,l=int(t),int(l) int(t) t
class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

ide_ele=0

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

def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f

import sys

input=sys.stdin.readline

N=int(input())
S=input().rstrip()

init_val=[1<<(ord(S[i])-97) for i in range(N)]
test=SegTree(init_val,segfunc,ide_ele)

for _ in range(int(input())):
    t,l,r=input().split()
    t,l=int(t),int(l)
    if t==1:
        val=ord(r)-97
        test.update(l-1,1<<val)
    else:
        r=int(r)
        res=test.query(l-1,r)
        print(popcount(res))
