n = int(input())
_s = input()
q = int(input())
query = [input() for _ in range(q)]

def bitsum(_bit, i):
    s = 0
    while i > 0:
        s += _bit[i]
        i -= i & (-i)
    return s

def bitadd(_bit, i, x):
    while i <= n:
        _bit[i] += x
        i += i & (-i)
    return _bit

al = [chr(ord('a') + i) for i in range(26)]
al_to_idx = dict()
for i in range(26):
    al_to_idx[al[i]] = i

s = list(_s)

# init
import math
n_ = int(math.log(n) / math.log(2)) + 1
bit = [[0] * (2 ** n_ + 1) for _ in range(26)]
for i in range(n):
    idx = al_to_idx[s[i]]
    bit[idx] = bitadd(bit[idx], i + 1, 1)
# print(bit)

for i in range(q):
    _query = query[i].split(' ')
    if _query[0] == '1':
        # decrement old
        idx = al_to_idx[s[int(_query[1]) - 1]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), -1)

        s[int(_query[1]) - 1] = _query[2]
        # print(s)

        # increment
        idx = al_to_idx[_query[2]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), 1)

    else:
        _ans = 0
        for idx in range(26):
            _bit = bit[idx]
            c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1)
            if c != 0:
                _ans += 1
        print(_ans) n = int(input()) n int(input()) int input() input _s = input() _s input() input q = int(input()) q int(input()) int input() input input() for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) input() input query = [input() for _ in range(q)] query [input() for _ in range(q)] def bitsum(_bit, i):
    s = 0
    while i > 0:
        s += _bit[i]
        i -= i & (-i)
    return s bitsum s = 0 s 0 while i > 0:
        s += _bit[i]
        i -= i & (-i)
     i > 0 i 0 s += _bit[i] s _bit[i] _bit i i -= i & (-i) i i & (-i) i -i i return s s _bit _bit i i def bitadd(_bit, i, x):
    while i <= n:
        _bit[i] += x
        i += i & (-i)
    return _bit bitadd while i <= n:
        _bit[i] += x
        i += i & (-i)
     i <= n i n _bit[i] += x _bit[i] _bit i x i += i & (-i) i i & (-i) i -i i return _bit _bit _bit _bit i i x x chr(ord('a') + i) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(ord('a') + i) chr ord('a') + i ord('a') ord 'a' i al = [chr(ord('a') + i) for i in range(26)] al [chr(ord('a') + i) for i in range(26)] al_to_idx = dict() al_to_idx dict() dict for i in range(26):
    al_to_idx[al[i]] = i i range(26) range 26 al_to_idx[al[i]] = i al_to_idx[al[i]] al_to_idx al[i] al i i s = list(_s) s list(_s) list _s import math math n_ = int(math.log(n) / math.log(2)) + 1 n_ int(math.log(n) / math.log(2)) + 1 int(math.log(n) / math.log(2)) int math.log(n) / math.log(2) math.log(n) math.log math log n math.log(2) math.log math log 2 1 [0] * (2 ** n_ + 1) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [0] * (2 ** n_ + 1) [0] 0 2 ** n_ + 1 2 ** n_ 2 n_ 1 bit = [[0] * (2 ** n_ + 1) for _ in range(26)] bit [[0] * (2 ** n_ + 1) for _ in range(26)] for i in range(n):
    idx = al_to_idx[s[i]]
    bit[idx] = bitadd(bit[idx], i + 1, 1)
# print(bit) i range(n) range n idx = al_to_idx[s[i]] idx al_to_idx[s[i]] al_to_idx s[i] s i bit[idx] = bitadd(bit[idx], i + 1, 1) bit[idx] bit idx bitadd(bit[idx], i + 1, 1) bitadd bit[idx] bit idx i + 1 i 1 1 for i in range(q):
    _query = query[i].split(' ')
    if _query[0] == '1':
        # decrement old
        idx = al_to_idx[s[int(_query[1]) - 1]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), -1)

        s[int(_query[1]) - 1] = _query[2]
        # print(s)

        # increment
        idx = al_to_idx[_query[2]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), 1)

    else:
        _ans = 0
        for idx in range(26):
            _bit = bit[idx]
            c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1)
            if c != 0:
                _ans += 1
        print(_ans) i range(q) range q _query = query[i].split(' ') _query query[i].split(' ') [i].split [i] query i split ' ' if _query[0] == '1':
        # decrement old
        idx = al_to_idx[s[int(_query[1]) - 1]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), -1)

        s[int(_query[1]) - 1] = _query[2]
        # print(s)

        # increment
        idx = al_to_idx[_query[2]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), 1)

    else:
        _ans = 0
        for idx in range(26):
            _bit = bit[idx]
            c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1)
            if c != 0:
                _ans += 1
        print(_ans) _query[0] == '1' _query[0] _query 0 '1' idx = al_to_idx[s[int(_query[1]) - 1]] idx al_to_idx[s[int(_query[1]) - 1]] al_to_idx s[int(_query[1]) - 1] s int(_query[1]) - 1 int(_query[1]) int _query[1] _query 1 1 bit[idx] = bitadd(bit[idx], int(_query[1]), -1) bit[idx] bit idx bitadd(bit[idx], int(_query[1]), -1) bitadd bit[idx] bit idx int(_query[1]) int _query[1] _query 1 -1 s[int(_query[1]) - 1] = _query[2] s[int(_query[1]) - 1] s int(_query[1]) - 1 int(_query[1]) int _query[1] _query 1 1 _query[2] _query 2 idx = al_to_idx[_query[2]] idx al_to_idx[_query[2]] al_to_idx _query[2] _query 2 bit[idx] = bitadd(bit[idx], int(_query[1]), 1) bit[idx] bit idx bitadd(bit[idx], int(_query[1]), 1) bitadd bit[idx] bit idx int(_query[1]) int _query[1] _query 1 1 _ans = 0 _ans 0 for idx in range(26):
            _bit = bit[idx]
            c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1)
            if c != 0:
                _ans += 1
         idx range(26) range 26 _bit = bit[idx] _bit bit[idx] bit idx c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1) c bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1) bitsum(_bit, int(_query[2])) bitsum _bit int(_query[2]) int _query[2] _query 2 bitsum(_bit, int(_query[1]) - 1) bitsum _bit int(_query[1]) - 1 int(_query[1]) int _query[1] _query 1 1 if c != 0:
                _ans += 1
         c != 0 c 0 _ans += 1 _ans 1 print(_ans) print _ans al = [chr(ord('a') + i) for i in range(26)] [chr(ord('a') + i) for i in range(26)] al _ans = 0 0 _ans def bitsum(_bit, i):
    s = 0
    while i > 0:
        s += _bit[i]
        i -= i & (-i)
    return s def bitsum(_bit, i):
    s = 0
    while i > 0:
        s += _bit[i]
        i -= i & (-i)
    return s bitsum idx = al_to_idx[s[i]] al_to_idx[s[i]] idx n = int(input()) int(input()) n _query = query[i].split(' ') query[i].split(' ') _query c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1) bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1) c n_ = int(math.log(n) / math.log(2)) + 1 int(math.log(n) / math.log(2)) + 1 n_ s = list(_s) list(_s) s idx = al_to_idx[_query[2]] al_to_idx[_query[2]] idx q = int(input()) int(input()) q _s = input() input() _s al_to_idx = dict() dict() al_to_idx idx = al_to_idx[s[int(_query[1]) - 1]] al_to_idx[s[int(_query[1]) - 1]] idx _bit = bit[idx] bit[idx] _bit query = [input() for _ in range(q)] [input() for _ in range(q)] query def bitadd(_bit, i, x):
    while i <= n:
        _bit[i] += x
        i += i & (-i)
    return _bit def bitadd(_bit, i, x):
    while i <= n:
        _bit[i] += x
        i += i & (-i)
    return _bit bitadd bit = [[0] * (2 ** n_ + 1) for _ in range(26)] [[0] * (2 ** n_ + 1) for _ in range(26)] bit _ans += 1 1 _ans
n = int(input())
_s = input()
q = int(input())
query = [input() for _ in range(q)]

def bitsum(_bit, i):
    s = 0
    while i > 0:
        s += _bit[i]
        i -= i & (-i)
    return s

def bitadd(_bit, i, x):
    while i <= n:
        _bit[i] += x
        i += i & (-i)
    return _bit

al = [chr(ord('a') + i) for i in range(26)]
al_to_idx = dict()
for i in range(26):
    al_to_idx[al[i]] = i

s = list(_s)

# init
import math
n_ = int(math.log(n) / math.log(2)) + 1
bit = [[0] * (2 ** n_ + 1) for _ in range(26)]
for i in range(n):
    idx = al_to_idx[s[i]]
    bit[idx] = bitadd(bit[idx], i + 1, 1)
# print(bit)

for i in range(q):
    _query = query[i].split(' ')
    if _query[0] == '1':
        # decrement old
        idx = al_to_idx[s[int(_query[1]) - 1]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), -1)

        s[int(_query[1]) - 1] = _query[2]
        # print(s)

        # increment
        idx = al_to_idx[_query[2]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), 1)

    else:
        _ans = 0
        for idx in range(26):
            _bit = bit[idx]
            c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1)
            if c != 0:
                _ans += 1
        print(_ans)
