n = int(input())
s = input()
table = {x: 2**i for i, x in enumerate(map(chr, range(97, 123)))}

SEG_LEN = n
SEG = [0]*(SEG_LEN*2)


def update(i, x):
    i += SEG_LEN
    SEG[i] = table[x]
    while i > 0:
        i //= 2
        SEG[i] = SEG[i*2] | SEG[i*2+1]


def find(left, right):
    left += SEG_LEN
    right += SEG_LEN
    ans = 0
    while left < right:
        if left % 2 == 1:
            ans = SEG[left] | ans
            left += 1
        left //= 2
        if right % 2 == 1:
            ans = SEG[right-1] | ans
            right -= 1
        right //= 2
    return format(ans, 'b').count('1')


for i, c in enumerate(s):
    update(i, c)

q = int(input())
for _ in range(q):
    com, *query = input().split()
    if com == '1':
        idx, x = query
        update(int(idx)-1, x)
    else:
        L, R = map(int, query)
        print(find(L-1, R)) n = int(input()) n int(input()) int input() input s = input() s input() input x: 2**i for i, x in enumerate(map(chr, range(97, 123))) for i, x in enumerate(map(chr, range(97, 123))) i x enumerate(map(chr, range(97, 123))) enumerate map(chr, range(97, 123)) map chr range(97, 123) range 97 123 for i, x in enumerate(map(chr, range(97, 123))) x 2**i 2 i table = {x: 2**i for i, x in enumerate(map(chr, range(97, 123)))} table {x: 2**i for i, x in enumerate(map(chr, range(97, 123)))} SEG_LEN = n SEG_LEN n SEG = [0]*(SEG_LEN*2) SEG [0]*(SEG_LEN*2) [0] 0 SEG_LEN*2 SEG_LEN 2 def update(i, x):
    i += SEG_LEN
    SEG[i] = table[x]
    while i > 0:
        i //= 2
        SEG[i] = SEG[i*2] | SEG[i*2+1] update i += SEG_LEN i SEG_LEN SEG[i] = table[x] SEG[i] SEG i table[x] table x while i > 0:
        i //= 2
        SEG[i] = SEG[i*2] | SEG[i*2+1] i > 0 i 0 i //= 2 i 2 SEG[i] = SEG[i*2] | SEG[i*2+1] SEG[i] SEG i SEG[i*2] | SEG[i*2+1] SEG[i*2] SEG i*2 i 2 SEG[i*2+1] SEG i*2+1 i*2 i 2 1 i i x x def find(left, right):
    left += SEG_LEN
    right += SEG_LEN
    ans = 0
    while left < right:
        if left % 2 == 1:
            ans = SEG[left] | ans
            left += 1
        left //= 2
        if right % 2 == 1:
            ans = SEG[right-1] | ans
            right -= 1
        right //= 2
    return format(ans, 'b').count('1') find left += SEG_LEN left SEG_LEN right += SEG_LEN right SEG_LEN ans = 0 ans 0 while left < right:
        if left % 2 == 1:
            ans = SEG[left] | ans
            left += 1
        left //= 2
        if right % 2 == 1:
            ans = SEG[right-1] | ans
            right -= 1
        right //= 2
     left < right left right if left % 2 == 1:
            ans = SEG[left] | ans
            left += 1
         left % 2 == 1 left % 2 left 2 1 ans = SEG[left] | ans ans SEG[left] | ans SEG[left] SEG left ans left += 1 left 1 left //= 2 left 2 if right % 2 == 1:
            ans = SEG[right-1] | ans
            right -= 1
         right % 2 == 1 right % 2 right 2 1 ans = SEG[right-1] | ans ans SEG[right-1] | ans SEG[right-1] SEG right-1 right 1 ans right -= 1 right 1 right //= 2 right 2 return format(ans, 'b').count('1') format(ans, 'b').count('1') (ans, 'b').count (ans, 'b') format ans 'b' count '1' left left right right for i, c in enumerate(s):
    update(i, c) i c enumerate(s) enumerate s update(i, c) update i c q = int(input()) q int(input()) int input() input for _ in range(q):
    com, *query = input().split()
    if com == '1':
        idx, x = query
        update(int(idx)-1, x)
    else:
        L, R = map(int, query)
        print(find(L-1, R)) _ range(q) range q com, *query = input().split() com input().split() ().split () input split *query query if com == '1':
        idx, x = query
        update(int(idx)-1, x)
    else:
        L, R = map(int, query)
        print(find(L-1, R)) com == '1' com '1' idx, x = query idx query x update(int(idx)-1, x) update int(idx)-1 int(idx) int idx 1 x L, R = map(int, query) L map(int, query) map int query R print(find(L-1, R)) print find(L-1, R) find L-1 L 1 R q = int(input()) int(input()) q s = input() input() s R = map(int, query) map(int, query) R x = query query x SEG = [0]*(SEG_LEN*2) [0]*(SEG_LEN*2) SEG com, *query = input().split() input().split() com def update(i, x):
    i += SEG_LEN
    SEG[i] = table[x]
    while i > 0:
        i //= 2
        SEG[i] = SEG[i*2] | SEG[i*2+1] def update(i, x):
    i += SEG_LEN
    SEG[i] = table[x]
    while i > 0:
        i //= 2
        SEG[i] = SEG[i*2] | SEG[i*2+1] update def find(left, right):
    left += SEG_LEN
    right += SEG_LEN
    ans = 0
    while left < right:
        if left % 2 == 1:
            ans = SEG[left] | ans
            left += 1
        left //= 2
        if right % 2 == 1:
            ans = SEG[right-1] | ans
            right -= 1
        right //= 2
    return format(ans, 'b').count('1') def find(left, right):
    left += SEG_LEN
    right += SEG_LEN
    ans = 0
    while left < right:
        if left % 2 == 1:
            ans = SEG[left] | ans
            left += 1
        left //= 2
        if right % 2 == 1:
            ans = SEG[right-1] | ans
            right -= 1
        right //= 2
    return format(ans, 'b').count('1') find n = int(input()) int(input()) n L, R = map(int, query) map(int, query) L table = {x: 2**i for i, x in enumerate(map(chr, range(97, 123)))} {x: 2**i for i, x in enumerate(map(chr, range(97, 123)))} table SEG_LEN = n n SEG_LEN idx, x = query query idx
n = int(input())
s = input()
table = {x: 2**i for i, x in enumerate(map(chr, range(97, 123)))}

SEG_LEN = n
SEG = [0]*(SEG_LEN*2)


def update(i, x):
    i += SEG_LEN
    SEG[i] = table[x]
    while i > 0:
        i //= 2
        SEG[i] = SEG[i*2] | SEG[i*2+1]


def find(left, right):
    left += SEG_LEN
    right += SEG_LEN
    ans = 0
    while left < right:
        if left % 2 == 1:
            ans = SEG[left] | ans
            left += 1
        left //= 2
        if right % 2 == 1:
            ans = SEG[right-1] | ans
            right -= 1
        right //= 2
    return format(ans, 'b').count('1')


for i, c in enumerate(s):
    update(i, c)

q = int(input())
for _ in range(q):
    com, *query = input().split()
    if com == '1':
        idx, x = query
        update(int(idx)-1, x)
    else:
        L, R = map(int, query)
        print(find(L-1, R))
