class SegmentTree(object):
    def __init__(self, sequence, function, identify):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.function = function
        self.data = [identify] * (self.length << 1)
        self.identify = identify
        # set values
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

    def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

    def query(self, p, q):
        if q <= p:
            return self.identify
        p += self.length - 1
        q += self.length - 2
        res = self.identify
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q])

def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


N = int(input())
S = input()
atoi = {chr(ord("a") + d): 1 << d for d in range(26)}
data = [atoi[c] for c in (S)]
seg_tree = SegmentTree(data, lambda a, b: a | b, 0)
Q = int(input())
for _ in range(Q):
    q, a, b = input().split()
    if q == "1":
        idx = int(a) - 1
        seg_tree.update(idx, atoi[b])
    else:
        print(popcount(seg_tree.query(int(a) - 1, int(b)))) class SegmentTree(object):
    def __init__(self, sequence, function, identify):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.function = function
        self.data = [identify] * (self.length << 1)
        self.identify = identify
        # set values
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

    def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

    def query(self, p, q):
        if q <= p:
            return self.identify
        p += self.length - 1
        q += self.length - 2
        res = self.identify
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q]) SegmentTree def __init__(self, sequence, function, identify):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.function = function
        self.data = [identify] * (self.length << 1)
        self.identify = identify
        # set values
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

     __init__ N = len(sequence) N len(sequence) len sequence self.length = (1 << (N - 1)).bit_length() self.length self length (1 << (N - 1)).bit_length() 1 << (N - 1)).bit_length 1 << (N - 1) 1 N - 1 N 1 bit_length self.function = function self.function self function function self.data = [identify] * (self.length << 1) self.data self data [identify] * (self.length << 1) [identify] identify self.length << 1 self.length self length 1 self.identify = identify self.identify self identify identify for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
         i range(N) range N self.data[i + self.length - 1] = sequence[i] self.data[i + self.length - 1] self.data self data i + self.length - 1 i + self.length i self.length self length 1 sequence[i] sequence i for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

     i range(self.length - 2, -1, -1) range self.length - 2 self.length self length 2 -1 -1 self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2]) self.data[i] self.data self data i self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2]) self.function self function self.data[(i << 1) + 1] self.data self data (i << 1) + 1 i << 1 i 1 1 self.data[(i << 1) + 2] self.data self data (i << 1) + 2 i << 1 i 1 2 self self sequence sequence function function identify identify def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

     update idx += self.length - 1 idx self.length - 1 self.length self length 1 self.data[idx] = x self.data[idx] self.data self data idx x while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

     idx idx = (idx - 1) >> 1 idx (idx - 1) >> 1 idx - 1 idx 1 1 self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2]) self.data[idx] self.data self data idx self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2]) self.function self function self.data[(idx << 1) + 1] self.data self data (idx << 1) + 1 idx << 1 idx 1 1 self.data[(idx << 1) + 2] self.data self data (idx << 1) + 2 idx << 1 idx 1 2 self self idx idx x x def query(self, p, q):
        if q <= p:
            return self.identify
        p += self.length - 1
        q += self.length - 2
        res = self.identify
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q]) query if q <= p:
            return self.identify
         q <= p q p return self.identify self.identify self identify p += self.length - 1 p self.length - 1 self.length self length 1 q += self.length - 2 q self.length - 2 self.length self length 2 res = self.identify res self.identify self identify while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
         q - p > 1 q - p q p 1 if not p & 1:
                res = self.function(res, self.data[p])
             not p & 1 p & 1 p 1 res = self.function(res, self.data[p]) res self.function(res, self.data[p]) self.function self function res self.data[p] self.data self data p if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
             q & 1 q 1 res = self.function(res, self.data[q]) res self.function(res, self.data[q]) self.function self function res self.data[q] self.data self data q q -= 1 q 1 p >>= 1 p 1 q = (q - 1) >> 1 q (q - 1) >> 1 q - 1 q 1 1 return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q]) self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q]) p == q p q self.function(res, self.data[p]) self.function self function res self.data[p] self.data self data p self.function(self.function(res, self.data[p]), self.data[q]) self.function self function self.function(res, self.data[p]) self.function self function res self.data[p] self.data self data p self.data[q] self.data self data q self self p p q q object def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f popcount x = x - ((x >> 1) & 0x5555555555555555) x x - ((x >> 1) & 0x5555555555555555) x (x >> 1) & 0x5555555555555555 x >> 1 x 1 0x5555555555555555 x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333) x (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333) x & 0x3333333333333333 x 0x3333333333333333 (x >> 2) & 0x3333333333333333 x >> 2 x 2 0x3333333333333333 x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f x (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f x + (x >> 4) x x >> 4 x 4 0x0f0f0f0f0f0f0f0f 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 x = x + (x >> 32) x x + (x >> 32) x x >> 32 x 32 return x & 0x0000007f x & 0x0000007f x 0x0000007f x x N = int(input()) N int(input()) int input() input S = input() S input() input chr(ord("a") + d): 1 << d for d in range(26) for d in range(26) d range(26) range 26 for d in range(26) chr(ord("a") + d) chr ord("a") + d ord("a") ord "a" d 1 << d 1 d atoi = {chr(ord("a") + d): 1 << d for d in range(26)} atoi {chr(ord("a") + d): 1 << d for d in range(26)} atoi[c] for c in (S) for c in (S) c S for c in (S) atoi[c] atoi c data = [atoi[c] for c in (S)] data [atoi[c] for c in (S)] seg_tree = SegmentTree(data, lambda a, b: a | b, 0) seg_tree SegmentTree(data, lambda a, b: a | b, 0) SegmentTree data lambda a, b: a | b a | b a b a b 0 Q = int(input()) Q int(input()) int input() input for _ in range(Q):
    q, a, b = input().split()
    if q == "1":
        idx = int(a) - 1
        seg_tree.update(idx, atoi[b])
    else:
        print(popcount(seg_tree.query(int(a) - 1, int(b)))) _ range(Q) range Q q, a, b = input().split() q input().split() ().split () input split a b if q == "1":
        idx = int(a) - 1
        seg_tree.update(idx, atoi[b])
    else:
        print(popcount(seg_tree.query(int(a) - 1, int(b)))) q == "1" q "1" idx = int(a) - 1 idx int(a) - 1 int(a) int a 1 seg_tree.update(idx, atoi[b]) seg_tree.update seg_tree update idx atoi[b] atoi b print(popcount(seg_tree.query(int(a) - 1, int(b)))) print popcount(seg_tree.query(int(a) - 1, int(b))) popcount seg_tree.query(int(a) - 1, int(b)) seg_tree.query seg_tree query int(a) - 1 int(a) int a 1 int(b) int b idx = int(a) - 1 int(a) - 1 idx S = input() input() S atoi = {chr(ord("a") + d): 1 << d for d in range(26)} {chr(ord("a") + d): 1 << d for d in range(26)} atoi seg_tree = SegmentTree(data, lambda a, b: a | b, 0) SegmentTree(data, lambda a, b: a | b, 0) seg_tree N = int(input()) int(input()) N Q = int(input()) int(input()) Q a, b = input().split() input().split() a q, a, b = input().split() input().split() q class SegmentTree(object):
    def __init__(self, sequence, function, identify):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.function = function
        self.data = [identify] * (self.length << 1)
        self.identify = identify
        # set values
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

    def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

    def query(self, p, q):
        if q <= p:
            return self.identify
        p += self.length - 1
        q += self.length - 2
        res = self.identify
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q]) class SegmentTree(object):
    def __init__(self, sequence, function, identify):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.function = function
        self.data = [identify] * (self.length << 1)
        self.identify = identify
        # set values
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

    def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

    def query(self, p, q):
        if q <= p:
            return self.identify
        p += self.length - 1
        q += self.length - 2
        res = self.identify
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q]) SegmentTree def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f popcount data = [atoi[c] for c in (S)] [atoi[c] for c in (S)] data b = input().split() input().split() b
class SegmentTree(object):
    def __init__(self, sequence, function, identify):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.function = function
        self.data = [identify] * (self.length << 1)
        self.identify = identify
        # set values
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

    def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

    def query(self, p, q):
        if q <= p:
            return self.identify
        p += self.length - 1
        q += self.length - 2
        res = self.identify
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q])

def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


N = int(input())
S = input()
atoi = {chr(ord("a") + d): 1 << d for d in range(26)}
data = [atoi[c] for c in (S)]
seg_tree = SegmentTree(data, lambda a, b: a | b, 0)
Q = int(input())
for _ in range(Q):
    q, a, b = input().split()
    if q == "1":
        idx = int(a) - 1
        seg_tree.update(idx, atoi[b])
    else:
        print(popcount(seg_tree.query(int(a) - 1, int(b))))