import sys
input = sys.stdin.readline
N = int(input())
S = list(map(lambda x: ord(x) - ord("a"), list(input())[: -1]))

class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[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)
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1

fwk = [BIT(N) for _ in range(26)]
for i in range(N): fwk[S[i]].add(i + 1, 1)
for _ in range(int(input())):
  q, x, y = input().split()
  if q == "1":
    x = int(x)
    y = ord(y) - ord("a")
    fwk[S[x - 1]].add(x, -1)
    fwk[y].add(x, 1)
    S[x - 1] = y
  else:
    x = int(x)
    y = int(y)
    res = 0
    for i in range(26): res += fwk[i].get(x - 1, y) > 0
    print(res) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input S = list(map(lambda x: ord(x) - ord("a"), list(input())[: -1])) S list(map(lambda x: ord(x) - ord("a"), list(input())[: -1])) list map(lambda x: ord(x) - ord("a"), list(input())[: -1]) map lambda x: ord(x) - ord("a") ord(x) - ord("a") ord(x) ord x ord("a") ord "a" x list(input())[: -1] (input()) list input() input : -1 -1 class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[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)
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1 BIT def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
   __init__ self.n = n self.n self n n self.data = [0] * (n + 1) self.data self data [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.data[i]
      i -= i & -i
    return s
   sum s = 0 s 0 while i > 0:
      s += self.data[i]
      i -= i & -i
     i > 0 i 0 s += self.data[i] s self.data[i] self.data self data i i -= i & -i i i & -i i -i i return s s self self i i def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
   add self.el[i] += x self.el[i] self.el self el i x while i <= self.n:
      self.data[i] += x
      i += i & -i
   i <= self.n i self.n self n self.data[i] += x self.data[i] self.data self data 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)
   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) self.sum(j) - self.sum(i) self.sum(j) self.sum self sum j self.sum(i) self.sum self sum i self self i i j = None j None def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1 lowerbound x = 0 x 0 y = 0 y 0 for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
     i range(self.n.bit_length(), -1, -1) range self.n.bit_length() self.n.bit_length self.n self n bit_length -1 -1 k = x + (1 << i) k x + (1 << i) x 1 << i 1 i if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
     k <= self.n and (y + self.data[k] < s) k <= self.n k self.n self n y + self.data[k] < s y + self.data[k] y self.data[k] self.data self data k s y += self.data[k] y self.data[k] self.data self data k x += 1 << i x 1 << i 1 i return x + 1 x + 1 x 1 self self s s BIT(N) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) BIT(N) BIT N fwk = [BIT(N) for _ in range(26)] fwk [BIT(N) for _ in range(26)] for i in range(N): fwk[S[i]].add(i + 1, 1) i range(N) range N for _ in range(int(input())):
  q, x, y = input().split()
  if q == "1":
    x = int(x)
    y = ord(y) - ord("a")
    fwk[S[x - 1]].add(x, -1)
    fwk[y].add(x, 1)
    S[x - 1] = y
  else:
    x = int(x)
    y = int(y)
    res = 0
    for i in range(26): res += fwk[i].get(x - 1, y) > 0
    print(res) _ range(int(input())) range int(input()) int input() input q, x, y = input().split() q input().split() ().split () input split x y if q == "1":
    x = int(x)
    y = ord(y) - ord("a")
    fwk[S[x - 1]].add(x, -1)
    fwk[y].add(x, 1)
    S[x - 1] = y
  else:
    x = int(x)
    y = int(y)
    res = 0
    for i in range(26): res += fwk[i].get(x - 1, y) > 0
    print(res) q == "1" q "1" x = int(x) x int(x) int x y = ord(y) - ord("a") y ord(y) - ord("a") ord(y) ord y ord("a") ord "a" fwk[S[x - 1]].add(x, -1) [S[x - 1]].add [S[x - 1]] fwk S[x - 1] S x - 1 x 1 add x -1 fwk[y].add(x, 1) [y].add [y] fwk y add x 1 S[x - 1] = y S[x - 1] S x - 1 x 1 y x = int(x) x int(x) int x y = int(y) y int(y) int y res = 0 res 0 for i in range(26): res += fwk[i].get(x - 1, y) > 0
     i range(26) range 26 print(res) print res q, x, y = input().split() input().split() q x, y = input().split() input().split() x S = list(map(lambda x: ord(x) - ord("a"), list(input())[: -1])) list(map(lambda x: ord(x) - ord("a"), list(input())[: -1])) S class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[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)
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1 class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[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)
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1 BIT fwk = [BIT(N) for _ in range(26)] [BIT(N) for _ in range(26)] fwk y = ord(y) - ord("a") ord(y) - ord("a") y N = int(input()) int(input()) N input = sys.stdin.readline sys.stdin.readline input y = int(y) int(y) y y = input().split() input().split() y x = int(x) int(x) x x = int(x) int(x) x res = 0 0 res
import sys
input = sys.stdin.readline
N = int(input())
S = list(map(lambda x: ord(x) - ord("a"), list(input())[: -1]))

class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[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)
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1

fwk = [BIT(N) for _ in range(26)]
for i in range(N): fwk[S[i]].add(i + 1, 1)
for _ in range(int(input())):
  q, x, y = input().split()
  if q == "1":
    x = int(x)
    y = ord(y) - ord("a")
    fwk[S[x - 1]].add(x, -1)
    fwk[y].add(x, 1)
    S[x - 1] = y
  else:
    x = int(x)
    y = int(y)
    res = 0
    for i in range(26): res += fwk[i].get(x - 1, y) > 0
    print(res)