# Binary Indexed Tree (Fenwick Tree)
class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)
  def lower_bound(self,x):
    w = i = 0
    k = 1<<((self.n).bit_length())
    while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
    return i+1

def alph_to_num(s):
  return ord(s)-ord('a')

def solve():
  N = int(input())
  S = list(map(alph_to_num,list(input())))
  Q = int(input())
  bits = [BIT(N) for _ in range(26)]
  for i in range(N):
    bits[S[i]].add(i+1,1)
  ans = []
  for _ in range(Q):
    x,y,z = input().split()
    y = int(y)
    if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
    if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
  return ans
print(*solve(),sep='\n') class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)
  def lower_bound(self,x):
    w = i = 0
    k = 1<<((self.n).bit_length())
    while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
    return i+1 BIT def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
   __init__ self.n = n self.n self n n self.bit = [0]*(n+1) self.bit self bit [0]*(n+1) [0] 0 n+1 n 1 self.el = [0]*(n+1) self.el self el [0]*(n+1) [0] 0 n+1 n 1 self self n n def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
   sum s = 0 s 0 while i > 0:
      s += self.bit[i]
      i -= i & -i
     i > 0 i 0 s += self.bit[i] s self.bit[i] self.bit self bit i i -= i & -i i i & -i i -i i return s s self self i i def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
   add self.el[i] += x self.el[i] self.el self el i x while i <= self.n:
      self.bit[i] += x
      i += i & -i
   i <= self.n i self.n self n self.bit[i] += x self.bit[i] self.bit self bit i x i += i & -i i i & -i i -i i self self i i x x def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)
   get if j is None:
      return self.el[i]
     j is None j None return self.el[i] self.el[i] self.el self el i return self.sum(j) - self.sum(i-1) self.sum(j) - self.sum(i-1) self.sum(j) self.sum self sum j self.sum(i-1) self.sum self sum i-1 i 1 self self i i j=None j None def lower_bound(self,x):
    w = i = 0
    k = 1<<((self.n).bit_length())
    while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
    return i+1 lower_bound w = i = 0 w 0 = i = 0 i 0 k = 1<<((self.n).bit_length()) k 1<<((self.n).bit_length()) 1 (self.n).bit_length() self.n).bit_length self.n self n bit_length while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
     k if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
       i+k <= self.n and w + self.bit[i+k] < x i+k <= self.n i+k i k self.n self n w + self.bit[i+k] < x w + self.bit[i+k] w self.bit[i+k] self.bit self bit i+k i k x w += self.bit[i+k] w self.bit[i+k] self.bit self bit i+k i k i += k i k k >>= 1 k 1 return i+1 i+1 i 1 self self x x def alph_to_num(s):
  return ord(s)-ord('a') alph_to_num return ord(s)-ord('a') ord(s)-ord('a') ord(s) ord s ord('a') ord 'a' s s def solve():
  N = int(input())
  S = list(map(alph_to_num,list(input())))
  Q = int(input())
  bits = [BIT(N) for _ in range(26)]
  for i in range(N):
    bits[S[i]].add(i+1,1)
  ans = []
  for _ in range(Q):
    x,y,z = input().split()
    y = int(y)
    if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
    if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
  return ans solve N = int(input()) N int(input()) int input() input S = list(map(alph_to_num,list(input()))) S list(map(alph_to_num,list(input()))) list map(alph_to_num,list(input())) map alph_to_num list(input()) list input() input Q = int(input()) Q int(input()) int input() input BIT(N) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) BIT(N) BIT N bits = [BIT(N) for _ in range(26)] bits [BIT(N) for _ in range(26)] for i in range(N):
    bits[S[i]].add(i+1,1)
   i range(N) range N bits[S[i]].add(i+1,1) [S[i]].add [S[i]] bits S[i] S i add i+1 i 1 1 ans = [] ans [] for _ in range(Q):
    x,y,z = input().split()
    y = int(y)
    if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
    if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
   _ range(Q) range Q x,y,z = input().split() x input().split() ().split () input split y z y = int(y) y int(y) int y if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
     x=='1' x '1' z = alph_to_num(z) z alph_to_num(z) alph_to_num z bits[S[y-1]].add(y,-1) [S[y-1]].add [S[y-1]] bits S[y-1] S y-1 y 1 add y -1 S[y-1] = z S[y-1] S y-1 y 1 z bits[z].add(y,1) [z].add [z] bits z add y 1 if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
   x=='2' x '2' z = int(z) z int(z) int z bits[i].get(y,z)>0 for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) bits[i].get(y,z)>0 bits[i].get(y,z) [i].get [i] bits i get y z 0 ans.append(sum([bits[i].get(y,z)>0 for i in range(26)])) ans.append ans append sum([bits[i].get(y,z)>0 for i in range(26)]) sum [bits[i].get(y,z)>0 for i in range(26)] return ans ans print(*solve(),sep='\n') print *solve() solve() solve sep='\n' sep '\n' class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)
  def lower_bound(self,x):
    w = i = 0
    k = 1<<((self.n).bit_length())
    while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
    return i+1 class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)
  def lower_bound(self,x):
    w = i = 0
    k = 1<<((self.n).bit_length())
    while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
    return i+1 BIT def alph_to_num(s):
  return ord(s)-ord('a') def alph_to_num(s):
  return ord(s)-ord('a') alph_to_num def solve():
  N = int(input())
  S = list(map(alph_to_num,list(input())))
  Q = int(input())
  bits = [BIT(N) for _ in range(26)]
  for i in range(N):
    bits[S[i]].add(i+1,1)
  ans = []
  for _ in range(Q):
    x,y,z = input().split()
    y = int(y)
    if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
    if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
  return ans def solve():
  N = int(input())
  S = list(map(alph_to_num,list(input())))
  Q = int(input())
  bits = [BIT(N) for _ in range(26)]
  for i in range(N):
    bits[S[i]].add(i+1,1)
  ans = []
  for _ in range(Q):
    x,y,z = input().split()
    y = int(y)
    if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
    if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
  return ans solve
# Binary Indexed Tree (Fenwick Tree)
class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)
  def lower_bound(self,x):
    w = i = 0
    k = 1<<((self.n).bit_length())
    while k:
      if i+k <= self.n and w + self.bit[i+k] < x:
        w += self.bit[i+k]
        i += k
      k >>= 1
    return i+1

def alph_to_num(s):
  return ord(s)-ord('a')

def solve():
  N = int(input())
  S = list(map(alph_to_num,list(input())))
  Q = int(input())
  bits = [BIT(N) for _ in range(26)]
  for i in range(N):
    bits[S[i]].add(i+1,1)
  ans = []
  for _ in range(Q):
    x,y,z = input().split()
    y = int(y)
    if x=='1':
      z = alph_to_num(z)
      bits[S[y-1]].add(y,-1)
      S[y-1] = z
      bits[z].add(y,1)
    if x=='2':
      z = int(z)
      ans.append(sum([bits[i].get(y,z)>0 for i in range(26)]))
  return ans
print(*solve(),sep='\n')