import numpy as np
N = int(input())
S = list(input())
Q = int(input())
Q_list = [input().split() for _ in range(Q)]
t_list = []
for q in Q_list:
  type = int(q[0])
  if(type==1):
    S[int(q[1])-1] = q[2]
  else:
    s, e = int(q[1]), int(q[2])
    t = 0
    str_list = []
    t = len(np.unique(S[s-1:e]))
    t_list.append(t)
[print(t) for t in t_list]