class SegmentTree:
  """Segmant Tree for query process.

  Args:
    a (List[int]): array.
    identity (int): identity element with f.
  """
  def __init__(self, a, identity=0):
    self.a = a
    self.n = len(a)
    self.identity = identity
    self.depth = (self.n - 1).bit_length()
    self.segment = (1 << self.depth) - 1
    self.tree = [identity] * (self.segment * 2 + 1)
    self.tree[self.segment : self.n + self.segment] = a
    for i in range(self.segment - 1, -1, -1):
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def update(self, i: int, x: int):
    i += self.segment
    self.tree[i] = x
    while i:
      i = (i - 1) // 2
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def query(self, l: int, r: int) -> int:
    """Query at [l, r]

    Args:
      l (int): left
      r (int): right

    Returns:
      int: result
    """
    if l > r:
      return self.identity
    l += self.segment
    r += self.segment
    res = self.identity
    while l <= r:
      if not l & 1:
        res = self.f(self.tree[l], res)
      if r & 1:
        res = self.f(res, self.tree[r])
      l = l // 2
      r = (r - 2) // 2
    return res

  def f(self, x: int, y: int) -> int:
    return x | y

n = int(input())
s = input()
q = int(input())
a = ord('a')
segment_tree = SegmentTree([1 << (ord(c) - a) for c in s])
for _ in range(q):
  query = input().split()
  if query[0] == '1':
    i = int(query[1]) - 1
    c = query[2]
    segment_tree.update(i, 1 << (ord(c) - a))
  else:
    l = int(query[1]) - 1
    r = int(query[2]) - 1
    bit = segment_tree.query(l, r)
    print(format(bit, 'b').count('1')) class SegmentTree:
  """Segmant Tree for query process.

  Args:
    a (List[int]): array.
    identity (int): identity element with f.
  """
  def __init__(self, a, identity=0):
    self.a = a
    self.n = len(a)
    self.identity = identity
    self.depth = (self.n - 1).bit_length()
    self.segment = (1 << self.depth) - 1
    self.tree = [identity] * (self.segment * 2 + 1)
    self.tree[self.segment : self.n + self.segment] = a
    for i in range(self.segment - 1, -1, -1):
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def update(self, i: int, x: int):
    i += self.segment
    self.tree[i] = x
    while i:
      i = (i - 1) // 2
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def query(self, l: int, r: int) -> int:
    """Query at [l, r]

    Args:
      l (int): left
      r (int): right

    Returns:
      int: result
    """
    if l > r:
      return self.identity
    l += self.segment
    r += self.segment
    res = self.identity
    while l <= r:
      if not l & 1:
        res = self.f(self.tree[l], res)
      if r & 1:
        res = self.f(res, self.tree[r])
      l = l // 2
      r = (r - 2) // 2
    return res

  def f(self, x: int, y: int) -> int:
    return x | y SegmentTree """Segmant Tree for query process.

  Args:
    a (List[int]): array.
    identity (int): identity element with f.
  """ def __init__(self, a, identity=0):
    self.a = a
    self.n = len(a)
    self.identity = identity
    self.depth = (self.n - 1).bit_length()
    self.segment = (1 << self.depth) - 1
    self.tree = [identity] * (self.segment * 2 + 1)
    self.tree[self.segment : self.n + self.segment] = a
    for i in range(self.segment - 1, -1, -1):
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

   __init__ self.a = a self.a self a a self.n = len(a) self.n self n len(a) len a self.identity = identity self.identity self identity identity self.depth = (self.n - 1).bit_length() self.depth self depth (self.n - 1).bit_length() self.n - 1).bit_length self.n - 1 self.n self n 1 bit_length self.segment = (1 << self.depth) - 1 self.segment self segment (1 << self.depth) - 1 1 << self.depth 1 self.depth self depth 1 self.tree = [identity] * (self.segment * 2 + 1) self.tree self tree [identity] * (self.segment * 2 + 1) [identity] identity self.segment * 2 + 1 self.segment * 2 self.segment self segment 2 1 self.tree[self.segment : self.n + self.segment] = a self.tree[self.segment : self.n + self.segment] self.tree self tree self.segment : self.n + self.segment self.segment self segment self.n + self.segment self.n self n self.segment self segment a for i in range(self.segment - 1, -1, -1):
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

   i range(self.segment - 1, -1, -1) range self.segment - 1 self.segment self segment 1 -1 -1 self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2]) self.tree[i] self.tree self tree i self.f(self.tree[2*i+1], self.tree[2*i+2]) self.f self f self.tree[2*i+1] self.tree self tree 2*i+1 2*i 2 i 1 self.tree[2*i+2] self.tree self tree 2*i+2 2*i 2 i 2 self self a a identity=0 identity 0 def update(self, i: int, x: int):
    i += self.segment
    self.tree[i] = x
    while i:
      i = (i - 1) // 2
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

   update i += self.segment i self.segment self segment self.tree[i] = x self.tree[i] self.tree self tree i x while i:
      i = (i - 1) // 2
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

   i i = (i - 1) // 2 i (i - 1) // 2 i - 1 i 1 2 self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2]) self.tree[i] self.tree self tree i self.f(self.tree[2*i+1], self.tree[2*i+2]) self.f self f self.tree[2*i+1] self.tree self tree 2*i+1 2*i 2 i 1 self.tree[2*i+2] self.tree self tree 2*i+2 2*i 2 i 2 self self i: int i x: int x def query(self, l: int, r: int) -> int:
    """Query at [l, r]

    Args:
      l (int): left
      r (int): right

    Returns:
      int: result
    """
    if l > r:
      return self.identity
    l += self.segment
    r += self.segment
    res = self.identity
    while l <= r:
      if not l & 1:
        res = self.f(self.tree[l], res)
      if r & 1:
        res = self.f(res, self.tree[r])
      l = l // 2
      r = (r - 2) // 2
    return res

   query """Query at [l, r]

    Args:
      l (int): left
      r (int): right

    Returns:
      int: result
    """ if l > r:
      return self.identity
     l > r l r return self.identity self.identity self identity l += self.segment l self.segment self segment r += self.segment r self.segment self segment res = self.identity res self.identity self identity while l <= r:
      if not l & 1:
        res = self.f(self.tree[l], res)
      if r & 1:
        res = self.f(res, self.tree[r])
      l = l // 2
      r = (r - 2) // 2
     l <= r l r if not l & 1:
        res = self.f(self.tree[l], res)
       not l & 1 l & 1 l 1 res = self.f(self.tree[l], res) res self.f(self.tree[l], res) self.f self f self.tree[l] self.tree self tree l res if r & 1:
        res = self.f(res, self.tree[r])
       r & 1 r 1 res = self.f(res, self.tree[r]) res self.f(res, self.tree[r]) self.f self f res self.tree[r] self.tree self tree r l = l // 2 l l // 2 l 2 r = (r - 2) // 2 r (r - 2) // 2 r - 2 r 2 2 return res res self self l: int l r: int r def f(self, x: int, y: int) -> int:
    return x | y f return x | y x | y x y self self x: int x y: int y n = int(input()) n int(input()) int input() input s = input() s input() input q = int(input()) q int(input()) int input() input a = ord('a') a ord('a') ord 'a' 1 << (ord(c) - a) for c in s for c in s c s for c in s 1 << (ord(c) - a) 1 ord(c) - a ord(c) ord c a segment_tree = SegmentTree([1 << (ord(c) - a) for c in s]) segment_tree SegmentTree([1 << (ord(c) - a) for c in s]) SegmentTree [1 << (ord(c) - a) for c in s] for _ in range(q):
  query = input().split()
  if query[0] == '1':
    i = int(query[1]) - 1
    c = query[2]
    segment_tree.update(i, 1 << (ord(c) - a))
  else:
    l = int(query[1]) - 1
    r = int(query[2]) - 1
    bit = segment_tree.query(l, r)
    print(format(bit, 'b').count('1')) _ range(q) range q query = input().split() query input().split() ().split () input split if query[0] == '1':
    i = int(query[1]) - 1
    c = query[2]
    segment_tree.update(i, 1 << (ord(c) - a))
  else:
    l = int(query[1]) - 1
    r = int(query[2]) - 1
    bit = segment_tree.query(l, r)
    print(format(bit, 'b').count('1')) query[0] == '1' query[0] query 0 '1' i = int(query[1]) - 1 i int(query[1]) - 1 int(query[1]) int query[1] query 1 1 c = query[2] c query[2] query 2 segment_tree.update(i, 1 << (ord(c) - a)) segment_tree.update segment_tree update i 1 << (ord(c) - a) 1 ord(c) - a ord(c) ord c a l = int(query[1]) - 1 l int(query[1]) - 1 int(query[1]) int query[1] query 1 1 r = int(query[2]) - 1 r int(query[2]) - 1 int(query[2]) int query[2] query 2 1 bit = segment_tree.query(l, r) bit segment_tree.query(l, r) segment_tree.query segment_tree query l r print(format(bit, 'b').count('1')) print format(bit, 'b').count('1') (bit, 'b').count (bit, 'b') format bit 'b' count '1' class SegmentTree:
  """Segmant Tree for query process.

  Args:
    a (List[int]): array.
    identity (int): identity element with f.
  """
  def __init__(self, a, identity=0):
    self.a = a
    self.n = len(a)
    self.identity = identity
    self.depth = (self.n - 1).bit_length()
    self.segment = (1 << self.depth) - 1
    self.tree = [identity] * (self.segment * 2 + 1)
    self.tree[self.segment : self.n + self.segment] = a
    for i in range(self.segment - 1, -1, -1):
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def update(self, i: int, x: int):
    i += self.segment
    self.tree[i] = x
    while i:
      i = (i - 1) // 2
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def query(self, l: int, r: int) -> int:
    """Query at [l, r]

    Args:
      l (int): left
      r (int): right

    Returns:
      int: result
    """
    if l > r:
      return self.identity
    l += self.segment
    r += self.segment
    res = self.identity
    while l <= r:
      if not l & 1:
        res = self.f(self.tree[l], res)
      if r & 1:
        res = self.f(res, self.tree[r])
      l = l // 2
      r = (r - 2) // 2
    return res

  def f(self, x: int, y: int) -> int:
    return x | y class SegmentTree:
  """Segmant Tree for query process.

  Args:
    a (List[int]): array.
    identity (int): identity element with f.
  """
  def __init__(self, a, identity=0):
    self.a = a
    self.n = len(a)
    self.identity = identity
    self.depth = (self.n - 1).bit_length()
    self.segment = (1 << self.depth) - 1
    self.tree = [identity] * (self.segment * 2 + 1)
    self.tree[self.segment : self.n + self.segment] = a
    for i in range(self.segment - 1, -1, -1):
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def update(self, i: int, x: int):
    i += self.segment
    self.tree[i] = x
    while i:
      i = (i - 1) // 2
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def query(self, l: int, r: int) -> int:
    """Query at [l, r]

    Args:
      l (int): left
      r (int): right

    Returns:
      int: result
    """
    if l > r:
      return self.identity
    l += self.segment
    r += self.segment
    res = self.identity
    while l <= r:
      if not l & 1:
        res = self.f(self.tree[l], res)
      if r & 1:
        res = self.f(res, self.tree[r])
      l = l // 2
      r = (r - 2) // 2
    return res

  def f(self, x: int, y: int) -> int:
    return x | y SegmentTree l = int(query[1]) - 1 int(query[1]) - 1 l query = input().split() input().split() query s = input() input() s r = int(query[2]) - 1 int(query[2]) - 1 r q = int(input()) int(input()) q bit = segment_tree.query(l, r) segment_tree.query(l, r) bit segment_tree = SegmentTree([1 << (ord(c) - a) for c in s]) SegmentTree([1 << (ord(c) - a) for c in s]) segment_tree n = int(input()) int(input()) n i = int(query[1]) - 1 int(query[1]) - 1 i c = query[2] query[2] c a = ord('a') ord('a') a
class SegmentTree:
  """Segmant Tree for query process.

  Args:
    a (List[int]): array.
    identity (int): identity element with f.
  """
  def __init__(self, a, identity=0):
    self.a = a
    self.n = len(a)
    self.identity = identity
    self.depth = (self.n - 1).bit_length()
    self.segment = (1 << self.depth) - 1
    self.tree = [identity] * (self.segment * 2 + 1)
    self.tree[self.segment : self.n + self.segment] = a
    for i in range(self.segment - 1, -1, -1):
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def update(self, i: int, x: int):
    i += self.segment
    self.tree[i] = x
    while i:
      i = (i - 1) // 2
      self.tree[i] = self.f(self.tree[2*i+1], self.tree[2*i+2])

  def query(self, l: int, r: int) -> int:
    """Query at [l, r]

    Args:
      l (int): left
      r (int): right

    Returns:
      int: result
    """
    if l > r:
      return self.identity
    l += self.segment
    r += self.segment
    res = self.identity
    while l <= r:
      if not l & 1:
        res = self.f(self.tree[l], res)
      if r & 1:
        res = self.f(res, self.tree[r])
      l = l // 2
      r = (r - 2) // 2
    return res

  def f(self, x: int, y: int) -> int:
    return x | y

n = int(input())
s = input()
q = int(input())
a = ord('a')
segment_tree = SegmentTree([1 << (ord(c) - a) for c in s])
for _ in range(q):
  query = input().split()
  if query[0] == '1':
    i = int(query[1]) - 1
    c = query[2]
    segment_tree.update(i, 1 << (ord(c) - a))
  else:
    l = int(query[1]) - 1
    r = int(query[2]) - 1
    bit = segment_tree.query(l, r)
    print(format(bit, 'b').count('1'))