n, s, q = int(input()), input(), int(input())

class SegmentTree:
    def __init__(self, n, func=lambda x, y: min(x, y), ide=float("inf")):
        self.n = 2 ** (n-1).bit_length()
        self.data = [ide] * (self.n*2)
        self.func, self.ide = func, ide
    
    def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def update(self, i, x):
        i += self.n
        self.data[i] = x
        while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def query(self, l, r):
        l += self.n; r += self.n 
        res = self.ide
        while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l //= 2; r //= 2
        return res
    
    def get(self, i):
        return self.data[self.n + i]

st = [SegmentTree(n, lambda x, y: x+y, 0) for _ in range(26)]
for i, c in enumerate(s): st[ord(c)-97].update(i, 1)

for _ in range(q):
    a, b, c = input().split()
    if a == "1":
        idx = int(b)-1
        for i in range(26):
            st[i].update(idx, 0)
        st[ord(c)-97].update(idx, 1)
    else:
        l, r = int(b)-1, int(c)
        res = 0
        for i in range(26):
            res += bool(st[i].query(l, r))
        print(res) n, s, q = int(input()), input(), int(input()) n int(input()) int input() input s input() input q int(input()) int input() input class SegmentTree:
    def __init__(self, n, func=lambda x, y: min(x, y), ide=float("inf")):
        self.n = 2 ** (n-1).bit_length()
        self.data = [ide] * (self.n*2)
        self.func, self.ide = func, ide
    
    def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def update(self, i, x):
        i += self.n
        self.data[i] = x
        while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def query(self, l, r):
        l += self.n; r += self.n 
        res = self.ide
        while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l //= 2; r //= 2
        return res
    
    def get(self, i):
        return self.data[self.n + i] SegmentTree def __init__(self, n, func=lambda x, y: min(x, y), ide=float("inf")):
        self.n = 2 ** (n-1).bit_length()
        self.data = [ide] * (self.n*2)
        self.func, self.ide = func, ide
    
     __init__ self.n = 2 ** (n-1).bit_length() self.n self n 2 ** (n-1).bit_length() 2 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length self.data = [ide] * (self.n*2) self.data self data [ide] * (self.n*2) [ide] ide self.n*2 self.n self n 2 self.func, self.ide = func, ide self.func self func func self.ide self ide ide self self n n func=lambda x, y: min(x, y) func lambda x, y: min(x, y) min(x, y) min x y x y ide=float("inf") ide float("inf") float "inf" def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

     build for i, x in enumerate(data):
            self.data[self.n+i] = x
         i x enumerate(data) enumerate data self.data[self.n+i] = x self.data[self.n+i] self.data self data self.n+i self.n self n i x for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

     i range(self.n-1, 0, -1) range self.n-1 self.n self n 1 0 -1 self.data[i] = self.func(self.data[i*2], self.data[i*2+1]) self.data[i] self.data self data i self.func(self.data[i*2], self.data[i*2+1]) self.func self func self.data[i*2] self.data self data i*2 i 2 self.data[i*2+1] self.data self data i*2+1 i*2 i 2 1 self self data data def update(self, i, x):
        i += self.n
        self.data[i] = x
        while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

     update i += self.n i self.n self n self.data[i] = x self.data[i] self.data self data i x while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

     i > 1 i 1 i //= 2 i 2 self.data[i] = self.func(self.data[i*2], self.data[i*2+1]) self.data[i] self.data self data i self.func(self.data[i*2], self.data[i*2+1]) self.func self func self.data[i*2] self.data self data i*2 i 2 self.data[i*2+1] self.data self data i*2+1 i*2 i 2 1 self self i i x x def query(self, l, r):
        l += self.n; r += self.n 
        res = self.ide
        while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l //= 2; r //= 2
        return res
    
     query l += self.n l self.n self n r += self.n r self.n self n res = self.ide res self.ide self ide while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l //= 2; r //= 2
         l < r l r if l & 1:
                res = self.func(res, self.data[l])
                l += 1
             l & 1 l 1 res = self.func(res, self.data[l]) res self.func(res, self.data[l]) self.func self func res self.data[l] self.data self data l l += 1 l 1 if r & 1:
                res = self.func(res, self.data[r-1])
             r & 1 r 1 res = self.func(res, self.data[r-1]) res self.func(res, self.data[r-1]) self.func self func res self.data[r-1] self.data self data r-1 r 1 l //= 2 l 2 r //= 2 r 2 return res res self self l l r r def get(self, i):
        return self.data[self.n + i] get return self.data[self.n + i] self.data[self.n + i] self.data self data self.n + i self.n self n i self self i i SegmentTree(n, lambda x, y: x+y, 0) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) SegmentTree(n, lambda x, y: x+y, 0) SegmentTree n lambda x, y: x+y x+y x y x y 0 st = [SegmentTree(n, lambda x, y: x+y, 0) for _ in range(26)] st [SegmentTree(n, lambda x, y: x+y, 0) for _ in range(26)] for i, c in enumerate(s): st[ord(c)-97].update(i, 1) i c enumerate(s) enumerate s for _ in range(q):
    a, b, c = input().split()
    if a == "1":
        idx = int(b)-1
        for i in range(26):
            st[i].update(idx, 0)
        st[ord(c)-97].update(idx, 1)
    else:
        l, r = int(b)-1, int(c)
        res = 0
        for i in range(26):
            res += bool(st[i].query(l, r))
        print(res) _ range(q) range q a, b, c = input().split() a input().split() ().split () input split b c if a == "1":
        idx = int(b)-1
        for i in range(26):
            st[i].update(idx, 0)
        st[ord(c)-97].update(idx, 1)
    else:
        l, r = int(b)-1, int(c)
        res = 0
        for i in range(26):
            res += bool(st[i].query(l, r))
        print(res) a == "1" a "1" idx = int(b)-1 idx int(b)-1 int(b) int b 1 for i in range(26):
            st[i].update(idx, 0)
         i range(26) range 26 st[i].update(idx, 0) [i].update [i] st i update idx 0 st[ord(c)-97].update(idx, 1) [ord(c)-97].update [ord(c)-97] st ord(c)-97 ord(c) ord c 97 update idx 1 l, r = int(b)-1, int(c) l int(b)-1 int(b) int b 1 r int(c) int c res = 0 res 0 for i in range(26):
            res += bool(st[i].query(l, r))
         i range(26) range 26 res += bool(st[i].query(l, r)) res bool(st[i].query(l, r)) bool st[i].query(l, r) [i].query [i] st i query l r print(res) print res l, r = int(b)-1, int(c) int(b)-1 l res = 0 0 res res += bool(st[i].query(l, r)) bool(st[i].query(l, r)) res r = int(b)-1, int(c) int(c) r idx = int(b)-1 int(b)-1 idx s, q = int(input()), input(), int(input()) input() s q = int(input()), input(), int(input()) int(input()) q st = [SegmentTree(n, lambda x, y: x+y, 0) for _ in range(26)] [SegmentTree(n, lambda x, y: x+y, 0) for _ in range(26)] st n, s, q = int(input()), input(), int(input()) int(input()) n b, c = input().split() input().split() b c = input().split() input().split() c class SegmentTree:
    def __init__(self, n, func=lambda x, y: min(x, y), ide=float("inf")):
        self.n = 2 ** (n-1).bit_length()
        self.data = [ide] * (self.n*2)
        self.func, self.ide = func, ide
    
    def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def update(self, i, x):
        i += self.n
        self.data[i] = x
        while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def query(self, l, r):
        l += self.n; r += self.n 
        res = self.ide
        while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l //= 2; r //= 2
        return res
    
    def get(self, i):
        return self.data[self.n + i] class SegmentTree:
    def __init__(self, n, func=lambda x, y: min(x, y), ide=float("inf")):
        self.n = 2 ** (n-1).bit_length()
        self.data = [ide] * (self.n*2)
        self.func, self.ide = func, ide
    
    def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def update(self, i, x):
        i += self.n
        self.data[i] = x
        while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def query(self, l, r):
        l += self.n; r += self.n 
        res = self.ide
        while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l //= 2; r //= 2
        return res
    
    def get(self, i):
        return self.data[self.n + i] SegmentTree a, b, c = input().split() input().split() a
n, s, q = int(input()), input(), int(input())

class SegmentTree:
    def __init__(self, n, func=lambda x, y: min(x, y), ide=float("inf")):
        self.n = 2 ** (n-1).bit_length()
        self.data = [ide] * (self.n*2)
        self.func, self.ide = func, ide
    
    def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def update(self, i, x):
        i += self.n
        self.data[i] = x
        while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def query(self, l, r):
        l += self.n; r += self.n 
        res = self.ide
        while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l //= 2; r //= 2
        return res
    
    def get(self, i):
        return self.data[self.n + i]

st = [SegmentTree(n, lambda x, y: x+y, 0) for _ in range(26)]
for i, c in enumerate(s): st[ord(c)-97].update(i, 1)

for _ in range(q):
    a, b, c = input().split()
    if a == "1":
        idx = int(b)-1
        for i in range(26):
            st[i].update(idx, 0)
        st[ord(c)-97].update(idx, 1)
    else:
        l, r = int(b)-1, int(c)
        res = 0
        for i in range(26):
            res += bool(st[i].query(l, r))
        print(res)
