n = int(input())
s = list(input())
BITs = [[0]*(n+1) for _ in range(26)]

def c_idx(c):
    return ord(c) - 97

def query(pos):
    ret = [0]*26
    for i in range(26):
        tmp = 0
        p = pos
        while p > 0:
            tmp += BITs[i][p]
            p -= p & (-p)
        ret[i] = tmp
    return ret

def update(pos, a, x):
    while pos <= n:
        BITs[a][pos] += x
        pos += pos & (-pos)

for i in range(n):
    update(i+1, c_idx(s[i]), 1)
#print(BITs)

q = int(input())
for _ in range(q):
    a, b, c = input().split()
    b = int(b)
    if a == "1":
        if s[b-1] == c:
            continue
        update(b, c_idx(s[b-1]), -1)
        update(b, c_idx(c), 1)
        s[b-1] = c
    else:
        c = int(c)
        count1 = query(c)
        count2 = query(b-1)
        ans = 0
        for i in range(26):
            if count1[i] - count2[i] > 0:
                ans += 1
        print(ans) n = int(input()) n int(input()) int input() input s = list(input()) s list(input()) list input() input [0]*(n+1) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [0]*(n+1) [0] 0 n+1 n 1 BITs = [[0]*(n+1) for _ in range(26)] BITs [[0]*(n+1) for _ in range(26)] def c_idx(c):
    return ord(c) - 97 c_idx return ord(c) - 97 ord(c) - 97 ord(c) ord c 97 c c def query(pos):
    ret = [0]*26
    for i in range(26):
        tmp = 0
        p = pos
        while p > 0:
            tmp += BITs[i][p]
            p -= p & (-p)
        ret[i] = tmp
    return ret query ret = [0]*26 ret [0]*26 [0] 0 26 for i in range(26):
        tmp = 0
        p = pos
        while p > 0:
            tmp += BITs[i][p]
            p -= p & (-p)
        ret[i] = tmp
     i range(26) range 26 tmp = 0 tmp 0 p = pos p pos while p > 0:
            tmp += BITs[i][p]
            p -= p & (-p)
         p > 0 p 0 tmp += BITs[i][p] tmp BITs[i][p] [i] BITs i p p -= p & (-p) p p & (-p) p -p p ret[i] = tmp ret[i] ret i tmp return ret ret pos pos def update(pos, a, x):
    while pos <= n:
        BITs[a][pos] += x
        pos += pos & (-pos) update while pos <= n:
        BITs[a][pos] += x
        pos += pos & (-pos) pos <= n pos n BITs[a][pos] += x BITs[a][pos] [a] BITs a pos x pos += pos & (-pos) pos pos & (-pos) pos -pos pos pos pos a a x x for i in range(n):
    update(i+1, c_idx(s[i]), 1)
#print(BITs) i range(n) range n update(i+1, c_idx(s[i]), 1) update i+1 i 1 c_idx(s[i]) c_idx s[i] s i 1 q = int(input()) q int(input()) int input() input for _ in range(q):
    a, b, c = input().split()
    b = int(b)
    if a == "1":
        if s[b-1] == c:
            continue
        update(b, c_idx(s[b-1]), -1)
        update(b, c_idx(c), 1)
        s[b-1] = c
    else:
        c = int(c)
        count1 = query(c)
        count2 = query(b-1)
        ans = 0
        for i in range(26):
            if count1[i] - count2[i] > 0:
                ans += 1
        print(ans) _ range(q) range q a, b, c = input().split() a input().split() ().split () input split b c b = int(b) b int(b) int b if a == "1":
        if s[b-1] == c:
            continue
        update(b, c_idx(s[b-1]), -1)
        update(b, c_idx(c), 1)
        s[b-1] = c
    else:
        c = int(c)
        count1 = query(c)
        count2 = query(b-1)
        ans = 0
        for i in range(26):
            if count1[i] - count2[i] > 0:
                ans += 1
        print(ans) a == "1" a "1" if s[b-1] == c:
            continue
         s[b-1] == c s[b-1] s b-1 b 1 c continue update(b, c_idx(s[b-1]), -1) update b c_idx(s[b-1]) c_idx s[b-1] s b-1 b 1 -1 update(b, c_idx(c), 1) update b c_idx(c) c_idx c 1 s[b-1] = c s[b-1] s b-1 b 1 c c = int(c) c int(c) int c count1 = query(c) count1 query(c) query c count2 = query(b-1) count2 query(b-1) query b-1 b 1 ans = 0 ans 0 for i in range(26):
            if count1[i] - count2[i] > 0:
                ans += 1
         i range(26) range 26 if count1[i] - count2[i] > 0:
                ans += 1
         count1[i] - count2[i] > 0 count1[i] - count2[i] count1[i] count1 i count2[i] count2 i 0 ans += 1 ans 1 print(ans) print ans b, c = input().split() input().split() b c = int(c) int(c) c ans += 1 1 ans count2 = query(b-1) query(b-1) count2 s = list(input()) list(input()) s a, b, c = input().split() input().split() a ans = 0 0 ans n = int(input()) int(input()) n def update(pos, a, x):
    while pos <= n:
        BITs[a][pos] += x
        pos += pos & (-pos) def update(pos, a, x):
    while pos <= n:
        BITs[a][pos] += x
        pos += pos & (-pos) update q = int(input()) int(input()) q BITs = [[0]*(n+1) for _ in range(26)] [[0]*(n+1) for _ in range(26)] BITs c = input().split() input().split() c b = int(b) int(b) b def c_idx(c):
    return ord(c) - 97 def c_idx(c):
    return ord(c) - 97 c_idx def query(pos):
    ret = [0]*26
    for i in range(26):
        tmp = 0
        p = pos
        while p > 0:
            tmp += BITs[i][p]
            p -= p & (-p)
        ret[i] = tmp
    return ret def query(pos):
    ret = [0]*26
    for i in range(26):
        tmp = 0
        p = pos
        while p > 0:
            tmp += BITs[i][p]
            p -= p & (-p)
        ret[i] = tmp
    return ret query count1 = query(c) query(c) count1
n = int(input())
s = list(input())
BITs = [[0]*(n+1) for _ in range(26)]

def c_idx(c):
    return ord(c) - 97

def query(pos):
    ret = [0]*26
    for i in range(26):
        tmp = 0
        p = pos
        while p > 0:
            tmp += BITs[i][p]
            p -= p & (-p)
        ret[i] = tmp
    return ret

def update(pos, a, x):
    while pos <= n:
        BITs[a][pos] += x
        pos += pos & (-pos)

for i in range(n):
    update(i+1, c_idx(s[i]), 1)
#print(BITs)

q = int(input())
for _ in range(q):
    a, b, c = input().split()
    b = int(b)
    if a == "1":
        if s[b-1] == c:
            continue
        update(b, c_idx(s[b-1]), -1)
        update(b, c_idx(c), 1)
        s[b-1] = c
    else:
        c = int(c)
        count1 = query(c)
        count2 = query(b-1)
        ans = 0
        for i in range(26):
            if count1[i] - count2[i] > 0:
                ans += 1
        print(ans)