N = int(input())
S = list(input())
Q = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"
num = dict()
for i, var in enumerate(alphabet):
  num[var] = i

class Bit():
  def __init__(self, N):
    self.__N = N
    self.__arr = [[0] * 26 for _ in range(1 + N)]
    
  def add_(self, x, a, i):
    while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
  def sum_(self, x, i):
    res = 0
    while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
    return res
  
  def sub_sum_(self, x, y, i):
    return self.sum_(y, i) - self.sum_(x, i)

Bit = Bit(N)
for i, var in enumerate(S):
  Bit.add_(i+1, 1, num[var])

for i in range(Q):
  q, l, r = input().split()
  l = int(l)
  if q == "1" and r != S[l-1]:
    temp = S[l-1]
    S[l-1] = r
    Bit.add_(l, -1, num[temp])
    Bit.add_(l, 1, num[r])
  elif q == "2":
    r = int(r)
    res = 0
    for j in range(26):
      res += min(1, Bit.sub_sum_(l-1, r, j))
    print(res)    
     N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input Q = int(input()) Q int(input()) int input() input alphabet = "abcdefghijklmnopqrstuvwxyz" alphabet "abcdefghijklmnopqrstuvwxyz" num = dict() num dict() dict for i, var in enumerate(alphabet):
  num[var] = i i var enumerate(alphabet) enumerate alphabet num[var] = i num[var] num var i class Bit():
  def __init__(self, N):
    self.__N = N
    self.__arr = [[0] * 26 for _ in range(1 + N)]
    
  def add_(self, x, a, i):
    while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
  def sum_(self, x, i):
    res = 0
    while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
    return res
  
  def sub_sum_(self, x, y, i):
    return self.sum_(y, i) - self.sum_(x, i) Bit def __init__(self, N):
    self.__N = N
    self.__arr = [[0] * 26 for _ in range(1 + N)]
    
   __init__ self.__N = N self.__N self __N N [0] * 26 for _ in range(1 + N) for _ in range(1 + N) _ range(1 + N) range 1 + N 1 N for _ in range(1 + N) [0] * 26 [0] 0 26 self.__arr = [[0] * 26 for _ in range(1 + N)] self.__arr self __arr [[0] * 26 for _ in range(1 + N)] self self N N def add_(self, x, a, i):
    while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
   add_ while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
   x < self.__N + 1 x self.__N + 1 self.__N self __N 1 self.__arr[x][i] += a self.__arr[x][i] self.__arr[x] self.__arr self __arr x i a x += x & -x x x & -x x -x x self self x x a a i i def sum_(self, x, i):
    res = 0
    while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
    return res
  
   sum_ res = 0 res 0 while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
     x > 0 x 0 res += self.__arr[x][i] res self.__arr[x][i] self.__arr[x] self.__arr self __arr x i x -= x & -x x x & -x x -x x return res res self self x x i i def sub_sum_(self, x, y, i):
    return self.sum_(y, i) - self.sum_(x, i) sub_sum_ return self.sum_(y, i) - self.sum_(x, i) self.sum_(y, i) - self.sum_(x, i) self.sum_(y, i) self.sum_ self sum_ y i self.sum_(x, i) self.sum_ self sum_ x i self self x x y y i i Bit = Bit(N) Bit Bit(N) Bit N for i, var in enumerate(S):
  Bit.add_(i+1, 1, num[var]) i var enumerate(S) enumerate S Bit.add_(i+1, 1, num[var]) Bit.add_ Bit add_ i+1 i 1 1 num[var] num var for i in range(Q):
  q, l, r = input().split()
  l = int(l)
  if q == "1" and r != S[l-1]:
    temp = S[l-1]
    S[l-1] = r
    Bit.add_(l, -1, num[temp])
    Bit.add_(l, 1, num[r])
  elif q == "2":
    r = int(r)
    res = 0
    for j in range(26):
      res += min(1, Bit.sub_sum_(l-1, r, j))
    print(res)    
     i range(Q) range Q q, l, r = input().split() q input().split() ().split () input split l r l = int(l) l int(l) int l if q == "1" and r != S[l-1]:
    temp = S[l-1]
    S[l-1] = r
    Bit.add_(l, -1, num[temp])
    Bit.add_(l, 1, num[r])
  elif q == "2":
    r = int(r)
    res = 0
    for j in range(26):
      res += min(1, Bit.sub_sum_(l-1, r, j))
    print(res)    
     q == "1" and r != S[l-1] q == "1" q "1" r != S[l-1] r S[l-1] S l-1 l 1 temp = S[l-1] temp S[l-1] S l-1 l 1 S[l-1] = r S[l-1] S l-1 l 1 r Bit.add_(l, -1, num[temp]) Bit.add_ Bit add_ l -1 num[temp] num temp Bit.add_(l, 1, num[r]) Bit.add_ Bit add_ l 1 num[r] num r elif q == "2":
    r = int(r)
    res = 0
    for j in range(26):
      res += min(1, Bit.sub_sum_(l-1, r, j))
    print(res)    
     q == "2" q "2" r = int(r) r int(r) int r res = 0 res 0 for j in range(26):
      res += min(1, Bit.sub_sum_(l-1, r, j))
     j range(26) range 26 res += min(1, Bit.sub_sum_(l-1, r, j)) res min(1, Bit.sub_sum_(l-1, r, j)) min 1 Bit.sub_sum_(l-1, r, j) Bit.sub_sum_ Bit sub_sum_ l-1 l 1 r j print(res) print res res = 0 0 res Bit = Bit(N) Bit(N) Bit S = list(input()) list(input()) S alphabet = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" alphabet l, r = input().split() input().split() l temp = S[l-1] S[l-1] temp r = int(r) int(r) r Q = int(input()) int(input()) Q l = int(l) int(l) l q, l, r = input().split() input().split() q res += min(1, Bit.sub_sum_(l-1, r, j)) min(1, Bit.sub_sum_(l-1, r, j)) res N = int(input()) int(input()) N num = dict() dict() num class Bit():
  def __init__(self, N):
    self.__N = N
    self.__arr = [[0] * 26 for _ in range(1 + N)]
    
  def add_(self, x, a, i):
    while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
  def sum_(self, x, i):
    res = 0
    while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
    return res
  
  def sub_sum_(self, x, y, i):
    return self.sum_(y, i) - self.sum_(x, i) class Bit():
  def __init__(self, N):
    self.__N = N
    self.__arr = [[0] * 26 for _ in range(1 + N)]
    
  def add_(self, x, a, i):
    while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
  def sum_(self, x, i):
    res = 0
    while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
    return res
  
  def sub_sum_(self, x, y, i):
    return self.sum_(y, i) - self.sum_(x, i) Bit r = input().split() input().split() r
N = int(input())
S = list(input())
Q = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"
num = dict()
for i, var in enumerate(alphabet):
  num[var] = i

class Bit():
  def __init__(self, N):
    self.__N = N
    self.__arr = [[0] * 26 for _ in range(1 + N)]
    
  def add_(self, x, a, i):
    while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
  def sum_(self, x, i):
    res = 0
    while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
    return res
  
  def sub_sum_(self, x, y, i):
    return self.sum_(y, i) - self.sum_(x, i)

Bit = Bit(N)
for i, var in enumerate(S):
  Bit.add_(i+1, 1, num[var])

for i in range(Q):
  q, l, r = input().split()
  l = int(l)
  if q == "1" and r != S[l-1]:
    temp = S[l-1]
    S[l-1] = r
    Bit.add_(l, -1, num[temp])
    Bit.add_(l, 1, num[r])
  elif q == "2":
    r = int(r)
    res = 0
    for j in range(26):
      res += min(1, Bit.sub_sum_(l-1, r, j))
    print(res)    
    
