import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

class Node:
    def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

    def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree
class SegmentTree:
    def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

    def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

    def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

    def query(self, L, R):  #value of [L,R)
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

    def propagate(self, node_x, node_y):  # return parent if x,y is child
        return Node(node_x.val | node_y.val)


def main():
    N = iRaw()
    S = sRaw()
    sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S])
    Q = iRaw()
    ans =[]
    for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
    return "\n".join(map(str, ans))

if __name__ == "__main__":
    print(main()) import bisect bisect import math math from collections import deque def sRaw():
    return input().rstrip("\r") sRaw return input().rstrip("\r") input().rstrip("\r") ().rstrip () input rstrip "\r" def iRaw():
    return int(input()) iRaw return int(input()) int(input()) int input() input def ssRaw():
    return input().split() ssRaw return input().split() input().split() ().split () input split def isRaw():
    return list(map(int, ssRaw())) isRaw return list(map(int, ssRaw())) list(map(int, ssRaw())) list map(int, ssRaw()) map int ssRaw() ssRaw INF = 1 << 29 INF 1 << 29 1 29 class Node:
    def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

    def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree Node def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

     __init__ self.val = val self.val self val val self.idx = idx self.idx self idx idx self self val val idx=0 idx 0 def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree __str__ return 'val : ' + str(self.val) + ' idx : ' + str(self.idx) 'val : ' + str(self.val) + ' idx : ' + str(self.idx) 'val : ' + str(self.val) + ' idx : ' 'val : ' + str(self.val) 'val : ' str(self.val) str self.val self val ' idx : ' str(self.idx) str self.idx self idx self self class SegmentTree:
    def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

    def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

    def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

    def query(self, L, R):  #value of [L,R)
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

    def propagate(self, node_x, node_y):  # return parent if x,y is child
        return Node(node_x.val | node_y.val) SegmentTree def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

     __init__ self.N0 = pow(2, (N-1).bit_length()) self.N0 self N0 pow(2, (N-1).bit_length()) pow 2 (N-1).bit_length() N-1).bit_length N-1 N 1 bit_length Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1) for i in range(2*self.N0-1) i range(2*self.N0-1) range 2*self.N0-1 2*self.N0 2 self.N0 self N0 1 for i in range(2*self.N0-1) Node(default_value, i+1-self.N0) Node default_value i+1-self.N0 i+1 i 1 self.N0 self N0 self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)] self.nodes self nodes [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)] for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

     i reversed(range(2*self.N0-1)) reversed range(2*self.N0-1) range 2*self.N0-1 2*self.N0 2 self.N0 self N0 1 ind = i+1-self.N0 ind i+1-self.N0 i+1 i 1 self.N0 self N0 if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

     ind >= N ind N self.nodes[i].val = default_value self.nodes[i].val self.nodes[i] self.nodes self nodes i val default_value elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
             ind >=0 and N > ind ind >=0 ind 0 N > ind N ind self.nodes[i].val = vals[ind] self.nodes[i].val self.nodes[i] self.nodes self nodes i val vals[ind] vals ind self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2]) self.nodes[i] self.nodes self nodes i self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2]) self.propagate self propagate self.nodes[i*2+1] self.nodes self nodes i*2+1 i*2 i 2 1 self.nodes[i*2+2] self.nodes self nodes i*2+2 i*2 i 2 2 self self N N vals vals default_value=INF default_value INF def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

     __getitem__ return self.nodes[key+self.N0-1].val self.nodes[key+self.N0-1].val self.nodes[key+self.N0-1] self.nodes self nodes key+self.N0-1 key+self.N0 key self.N0 self N0 1 val self self key key def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

     __setitem__ i += self.N0 - 1 i self.N0 - 1 self.N0 self N0 1 self.nodes[i].val = x self.nodes[i].val self.nodes[i] self.nodes self nodes i val x while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

     i > 0 i 0 i = (i-1)//2 i (i-1)//2 i-1 i 1 2 self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2]) self.nodes[i] self.nodes self nodes i self.propagate(self.nodes[i*2+1], self.nodes[i*2+2]) self.propagate self propagate self.nodes[i*2+1] self.nodes self nodes i*2+1 i*2 i 2 1 self.nodes[i*2+2] self.nodes self nodes i*2+2 i*2 i 2 2 self self i i x x def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

     __str__ self.nodes[i+self.N0-1].val for i in range(self.N0) for i in range(self.N0) i range(self.N0) range self.N0 self N0 for i in range(self.N0) self.nodes[i+self.N0-1].val self.nodes[i+self.N0-1] self.nodes self nodes i+self.N0-1 i+self.N0 i self.N0 self N0 1 val return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']' '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']' '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)])) '[' ', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)])) ', '.join ', ' join map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]) map str [self.nodes[i+self.N0-1].val for i in range(self.N0)] ']' self self def query(self, L, R):  #value of [L,R)
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

     query retnode = Node(0, 0) retnode Node(0, 0) Node 0 0 L += self.N0 L self.N0 self N0 R += self.N0 R self.N0 self N0 while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
         L < R L R if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
             R & 1 R 1 R -= 1 R 1 retnode = self.propagate(retnode, self.nodes[R-1]) retnode self.propagate(retnode, self.nodes[R-1]) self.propagate self propagate retnode self.nodes[R-1] self.nodes self nodes R-1 R 1 if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
             L & 1 L 1 retnode = self.propagate(retnode, self.nodes[L-1]) retnode self.propagate(retnode, self.nodes[L-1]) self.propagate self propagate retnode self.nodes[L-1] self.nodes self nodes L-1 L 1 L += 1 L 1 L >>= 1 L 1 R >>= 1 R 1 return retnode retnode self self L L R R def propagate(self, node_x, node_y):  # return parent if x,y is child
        return Node(node_x.val | node_y.val) propagate return Node(node_x.val | node_y.val) Node(node_x.val | node_y.val) Node node_x.val | node_y.val node_x.val node_x val node_y.val node_y val self self node_x node_x node_y node_y def main():
    N = iRaw()
    S = sRaw()
    sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S])
    Q = iRaw()
    ans =[]
    for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
    return "\n".join(map(str, ans)) main N = iRaw() N iRaw() iRaw S = sRaw() S sRaw() sRaw 1 << (ord(s)-ord('a')) for s in S for s in S s S for s in S 1 << (ord(s)-ord('a')) 1 ord(s)-ord('a') ord(s) ord s ord('a') ord 'a' sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S]) sgt SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S]) SegmentTree N [1 << (ord(s)-ord('a')) for s in S] Q = iRaw() Q iRaw() iRaw ans =[] ans [] for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
     _ range(Q) range Q t,l,r = ssRaw() t ssRaw() ssRaw l r if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
     t=="1" t "1" sgt[int(l)-1] = 1 << (ord(r)-ord("a")) sgt[int(l)-1] sgt int(l)-1 int(l) int l 1 1 << (ord(r)-ord("a")) 1 ord(r)-ord("a") ord(r) ord r ord("a") ord "a" ret = sgt.query(int(l)-1, int(r)) ret sgt.query(int(l)-1, int(r)) sgt.query sgt query int(l)-1 int(l) int l 1 int(r) int r ans.append(str(bin(ret.val)).count("1")) ans.append ans append str(bin(ret.val)).count("1") (bin(ret.val)).count (bin(ret.val)) str bin(ret.val) bin ret.val ret val count "1" return "\n".join(map(str, ans)) "\n".join(map(str, ans)) "\n".join "\n" join map(str, ans) map str ans if __name__ == "__main__":
    print(main()) __name__ == "__main__" __name__ "__main__" print(main()) print main() main def ssRaw():
    return input().split() def ssRaw():
    return input().split() ssRaw def iRaw():
    return int(input()) def iRaw():
    return int(input()) iRaw def sRaw():
    return input().rstrip("\r") def sRaw():
    return input().rstrip("\r") sRaw class Node:
    def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

    def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree class Node:
    def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

    def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree Node INF = 1 << 29 1 << 29 INF def isRaw():
    return list(map(int, ssRaw())) def isRaw():
    return list(map(int, ssRaw())) isRaw class SegmentTree:
    def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

    def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

    def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

    def query(self, L, R):  #value of [L,R)
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

    def propagate(self, node_x, node_y):  # return parent if x,y is child
        return Node(node_x.val | node_y.val) class SegmentTree:
    def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

    def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

    def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

    def query(self, L, R):  #value of [L,R)
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

    def propagate(self, node_x, node_y):  # return parent if x,y is child
        return Node(node_x.val | node_y.val) SegmentTree def main():
    N = iRaw()
    S = sRaw()
    sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S])
    Q = iRaw()
    ans =[]
    for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
    return "\n".join(map(str, ans)) def main():
    N = iRaw()
    S = sRaw()
    sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S])
    Q = iRaw()
    ans =[]
    for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
    return "\n".join(map(str, ans)) main
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

class Node:
    def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

    def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree
class SegmentTree:
    def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

    def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

    def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

    def query(self, L, R):  #value of [L,R)
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

    def propagate(self, node_x, node_y):  # return parent if x,y is child
        return Node(node_x.val | node_y.val)


def main():
    N = iRaw()
    S = sRaw()
    sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S])
    Q = iRaw()
    ans =[]
    for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
    return "\n".join(map(str, ans))

if __name__ == "__main__":
    print(main())
