import bisect

N = int(input())
S = list(str(input()))

def ordN(x):
  return ord(x) - ord('a')

li = [[] for _ in range(26)]
for i,s in enumerate(S):
  li[ordN(s)].append(i)

for i in range(int(input())):
  Q1, Q2, Q3 = input().split()
  if Q1 == "1":
    Q2 = int(Q2) - 1
    if S[Q2] != Q3:
      I = bisect.bisect_left(li[ordN(S[Q2])], Q2)
      li[ordN(S[Q2])].pop(I)
      bisect.insort(li[ordN(Q3)], Q2)
      S[Q2] = Q3
  else:
    Q2, Q3 = int(Q2)-1, int(Q3)-1
    count = 0
    for j in range(26):
      I = bisect.bisect_left(li[j], Q2)
      if I < len(li[j]) and li[j][I] <= Q3:
        count += 1
    print(count) import bisect bisect N = int(input()) N int(input()) int input() input S = list(str(input())) S list(str(input())) list str(input()) str input() input def ordN(x):
  return ord(x) - ord('a') ordN return ord(x) - ord('a') ord(x) - ord('a') ord(x) ord x ord('a') ord 'a' x x [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] li = [[] for _ in range(26)] li [[] for _ in range(26)] for i,s in enumerate(S):
  li[ordN(s)].append(i) i s enumerate(S) enumerate S li[ordN(s)].append(i) [ordN(s)].append [ordN(s)] li ordN(s) ordN s append i for i in range(int(input())):
  Q1, Q2, Q3 = input().split()
  if Q1 == "1":
    Q2 = int(Q2) - 1
    if S[Q2] != Q3:
      I = bisect.bisect_left(li[ordN(S[Q2])], Q2)
      li[ordN(S[Q2])].pop(I)
      bisect.insort(li[ordN(Q3)], Q2)
      S[Q2] = Q3
  else:
    Q2, Q3 = int(Q2)-1, int(Q3)-1
    count = 0
    for j in range(26):
      I = bisect.bisect_left(li[j], Q2)
      if I < len(li[j]) and li[j][I] <= Q3:
        count += 1
    print(count) i range(int(input())) range int(input()) int input() input Q1, Q2, Q3 = input().split() Q1 input().split() ().split () input split Q2 Q3 if Q1 == "1":
    Q2 = int(Q2) - 1
    if S[Q2] != Q3:
      I = bisect.bisect_left(li[ordN(S[Q2])], Q2)
      li[ordN(S[Q2])].pop(I)
      bisect.insort(li[ordN(Q3)], Q2)
      S[Q2] = Q3
  else:
    Q2, Q3 = int(Q2)-1, int(Q3)-1
    count = 0
    for j in range(26):
      I = bisect.bisect_left(li[j], Q2)
      if I < len(li[j]) and li[j][I] <= Q3:
        count += 1
    print(count) Q1 == "1" Q1 "1" Q2 = int(Q2) - 1 Q2 int(Q2) - 1 int(Q2) int Q2 1 if S[Q2] != Q3:
      I = bisect.bisect_left(li[ordN(S[Q2])], Q2)
      li[ordN(S[Q2])].pop(I)
      bisect.insort(li[ordN(Q3)], Q2)
      S[Q2] = Q3
   S[Q2] != Q3 S[Q2] S Q2 Q3 I = bisect.bisect_left(li[ordN(S[Q2])], Q2) I bisect.bisect_left(li[ordN(S[Q2])], Q2) bisect.bisect_left bisect bisect_left li[ordN(S[Q2])] li ordN(S[Q2]) ordN S[Q2] S Q2 Q2 li[ordN(S[Q2])].pop(I) [ordN(S[Q2])].pop [ordN(S[Q2])] li ordN(S[Q2]) ordN S[Q2] S Q2 pop I bisect.insort(li[ordN(Q3)], Q2) bisect.insort bisect insort li[ordN(Q3)] li ordN(Q3) ordN Q3 Q2 S[Q2] = Q3 S[Q2] S Q2 Q3 Q2, Q3 = int(Q2)-1, int(Q3)-1 Q2 int(Q2)-1 int(Q2) int Q2 1 Q3 int(Q3)-1 int(Q3) int Q3 1 count = 0 count 0 for j in range(26):
      I = bisect.bisect_left(li[j], Q2)
      if I < len(li[j]) and li[j][I] <= Q3:
        count += 1
     j range(26) range 26 I = bisect.bisect_left(li[j], Q2) I bisect.bisect_left(li[j], Q2) bisect.bisect_left bisect bisect_left li[j] li j Q2 if I < len(li[j]) and li[j][I] <= Q3:
        count += 1
     I < len(li[j]) and li[j][I] <= Q3 I < len(li[j]) I len(li[j]) len li[j] li j li[j][I] <= Q3 li[j][I] [j] li j I Q3 count += 1 count 1 print(count) print count N = int(input()) int(input()) N I = bisect.bisect_left(li[ordN(S[Q2])], Q2) bisect.bisect_left(li[ordN(S[Q2])], Q2) I Q2, Q3 = int(Q2)-1, int(Q3)-1 int(Q2)-1 Q2 li = [[] for _ in range(26)] [[] for _ in range(26)] li Q1, Q2, Q3 = input().split() input().split() Q1 Q3 = int(Q2)-1, int(Q3)-1 int(Q3)-1 Q3 Q3 = input().split() input().split() Q3 Q2, Q3 = input().split() input().split() Q2 def ordN(x):
  return ord(x) - ord('a') def ordN(x):
  return ord(x) - ord('a') ordN S = list(str(input())) list(str(input())) S count = 0 0 count Q2 = int(Q2) - 1 int(Q2) - 1 Q2 I = bisect.bisect_left(li[j], Q2) bisect.bisect_left(li[j], Q2) I count += 1 1 count
import bisect

N = int(input())
S = list(str(input()))

def ordN(x):
  return ord(x) - ord('a')

li = [[] for _ in range(26)]
for i,s in enumerate(S):
  li[ordN(s)].append(i)

for i in range(int(input())):
  Q1, Q2, Q3 = input().split()
  if Q1 == "1":
    Q2 = int(Q2) - 1
    if S[Q2] != Q3:
      I = bisect.bisect_left(li[ordN(S[Q2])], Q2)
      li[ordN(S[Q2])].pop(I)
      bisect.insort(li[ordN(Q3)], Q2)
      S[Q2] = Q3
  else:
    Q2, Q3 = int(Q2)-1, int(Q3)-1
    count = 0
    for j in range(26):
      I = bisect.bisect_left(li[j], Q2)
      if I < len(li[j]) and li[j][I] <= Q3:
        count += 1
    print(count)