# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
class BIT:
  def __init__(self, logn):
    self.n = 1<<logn
    self.data = [0]*(self.n+1)
    self.el = [0]*(self.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):
    # assert i > 0
    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 bisect(self, x):
    w = i = 0
    k = self.n
    while k:
      if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
      k >>= 1
    return i+1

N = I()
A = list(S())
Q = I()

dic = {l:BIT(int_log(N,2)+1) for l in AZ}

for i in range(N):
  s = A[i]
  dic[s].add(i+1,1)

def change(i,y):
  prev = A[i-1]
  if prev == y:
    pass
  else:
    A[i-1] = y
    dic[prev].add(i,-1)
    dic[y].add(i,1)
  
def count(x,y):
  ret = 0
  for l in AZ:
    if dic[l].sum(x-1) != dic[l].sum(y):
      ret += 1
  print(ret)

for _ in range(Q):
  t,x,y = SL()
  if t == "1":
    change(int(x),y)
  else:
    count(int(x),int(y)) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline import math math import bisect bisect import heapq heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 INF = float('inf') INF float('inf') float 'inf' AZ = "abcdefghijklmnopqrstuvwxyz" AZ "abcdefghijklmnopqrstuvwxyz" def I(): return int(input().strip()) I def S(): return input().strip() S def IL(): return list(map(int,input().split())) IL def SL(): return list(map(str,input().split())) SL def ILs(n): return list(int(input()) for _ in range(n)) ILs n n def SLs(n): return list(input().strip() for _ in range(n)) SLs n n list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def ILL(n): return [list(map(int, input().split())) for _ in range(n)] ILL n n list(map(str, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(str, input().split())) list map(str, input().split()) map str input().split() ().split () input split def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT###### SLL n n def P(arg): print(arg); return P arg arg def Y(): print("Yes"); return Y def N(): print("No"); return N def E(): exit() E def PE(arg): print(arg); exit() PE arg arg def YE(): print("Yes"); exit() YE def NE(): print("No"); exit()

#####Shorten##### NE def DD(arg): return defaultdict(arg)

#####Inverse##### DD arg arg def inv(n): return pow(n, MOD-2, MOD)

######Combination###### inv n n kaijo_memo = [] kaijo_memo [] def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n] kaijo if(len(kaijo_memo) > n): return kaijo_memo[n]
   len(kaijo_memo) > n len(kaijo_memo) len kaijo_memo n if(len(kaijo_memo) == 0): kaijo_memo.append(1)
   len(kaijo_memo) == 0 len(kaijo_memo) len kaijo_memo 0 while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
   len(kaijo_memo) <= n len(kaijo_memo) len kaijo_memo n return kaijo_memo[n] kaijo_memo[n] kaijo_memo n n n gyaku_kaijo_memo = [] gyaku_kaijo_memo [] def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n] gyaku_kaijo if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
   len(gyaku_kaijo_memo) > n len(gyaku_kaijo_memo) len gyaku_kaijo_memo n if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
   len(gyaku_kaijo_memo) == 0 len(gyaku_kaijo_memo) len gyaku_kaijo_memo 0 while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
   len(gyaku_kaijo_memo) <= n len(gyaku_kaijo_memo) len gyaku_kaijo_memo n return gyaku_kaijo_memo[n] gyaku_kaijo_memo[n] gyaku_kaijo_memo n n n def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization###### nCr if n == r: return 1
   n == r n r if n < r or r < 0: return 0
   n < r or r < 0 n < r n r r < 0 r 0 ret = 1 ret 1 ret = ret * kaijo(n) % MOD ret ret * kaijo(n) % MOD ret * kaijo(n) ret kaijo(n) kaijo n MOD ret = ret * gyaku_kaijo(r) % MOD ret ret * gyaku_kaijo(r) % MOD ret * gyaku_kaijo(r) ret gyaku_kaijo(r) gyaku_kaijo r MOD ret = ret * gyaku_kaijo(n-r) % MOD ret ret * gyaku_kaijo(n-r) % MOD ret * gyaku_kaijo(n-r) ret gyaku_kaijo(n-r) gyaku_kaijo n-r n r MOD return ret ret n n r r def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors###### factorization arr = [] arr [] temp = n temp n for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
   i range(2, int(-(-n**0.5//1))+1) range 2 int(-(-n**0.5//1))+1 int(-(-n**0.5//1)) int -(-n**0.5//1) -n**0.5//1 -n**0.5 n**0.5 n 0.5 1 1 if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
   temp%i==0 temp%i temp i 0 cnt=0 cnt 0 while temp%i==0: 
        cnt+=1 
        temp //= i
       temp%i==0 temp%i temp i 0 cnt+=1 cnt 1 temp //= i temp i arr.append([i, cnt]) arr.append arr append [i, cnt] i cnt if temp!=1: arr.append([temp, 1])
   temp!=1 temp 1 if arr==[]: arr.append([n, 1])
   arr==[] arr [] return arr arr n n def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes###### make_divisors divisors = [] divisors [] for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
   i range(1, int(n**0.5)+1) range 1 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
   n % i == 0 n % i n i 0 divisors.append(i) divisors.append divisors append i if i != n // i: 
        divisors.append(n//i)
   i != n // i i n // i n i divisors.append(n//i) divisors.append divisors append n//i n i return divisors divisors n n def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD##### make_primes max = int(math.sqrt(N)) max int(math.sqrt(N)) int math.sqrt(N) math.sqrt math sqrt N i for i in range(2,N+1) for i in range(2,N+1) i range(2,N+1) range 2 N+1 N 1 for i in range(2,N+1) i seachList = [i for i in range(2,N+1)] seachList [i for i in range(2,N+1)] primeNum = [] primeNum [] while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
   seachList[0] <= max seachList[0] seachList 0 max primeNum.append(seachList[0]) primeNum.append primeNum append seachList[0] seachList 0 tmp = seachList[0] tmp seachList[0] seachList 0 i for i in seachList if i % tmp != 0 for i in seachList if i % tmp != 0 i seachList i % tmp != 0 i % tmp i tmp 0 if i % tmp != 0 i seachList = [i for i in seachList if i % tmp != 0] seachList [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) primeNum.extend primeNum extend seachList return primeNum primeNum N N def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM##### gcd while b: a, b = b, a % b
     b return a a a a b b def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount##### lcm return a * b // gcd (a, b) a * b // gcd (a, b) a * b a b gcd (a, b) gcd a b a a b b def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase##### count_bit count = 0 count 0 while n:
    n &= n-1
    count += 1
   n n &= n-1 n n-1 n 1 count += 1 count 1 return count count n n def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n] base_10_to_n if X//n: return base_10_to_n(X//n, n)+[X%n]
   X//n X n return [X%n] [X%n] X%n X n X X n n def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X)))) base_n_to_10 return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X)))) sum(int(str(X)[-i-1])*n**i for i in range(len(str(X)))) sum int(str(X)[-i-1])*n**i int(str(X)[-i-1]) int str(X)[-i-1] (X) str X -i-1 -i i 1 n**i n i X X n n def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog##### base_10_to_n_without_0 X -= 1 X 1 if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
   X//n X n return [X%n] [X%n] X%n X n X X n n def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
############# int_log count = 0 count 0 while n>=a:
    n //= a
    count += 1
   n>=a n a n //= a n a count += 1 count 1 return count count n n a a class BIT:
  def __init__(self, logn):
    self.n = 1<<logn
    self.data = [0]*(self.n+1)
    self.el = [0]*(self.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):
    # assert i > 0
    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 bisect(self, x):
    w = i = 0
    k = self.n
    while k:
      if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
      k >>= 1
    return i+1 BIT def __init__(self, logn):
    self.n = 1<<logn
    self.data = [0]*(self.n+1)
    self.el = [0]*(self.n+1)
   __init__ self.n = 1<<logn self.n self n 1<<logn 1 logn self.data = [0]*(self.n+1) self.data self data [0]*(self.n+1) [0] 0 self.n+1 self.n self n 1 self.el = [0]*(self.n+1) self.el self el [0]*(self.n+1) [0] 0 self.n+1 self.n self n 1 self self logn logn 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):
    # assert i > 0
    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 bisect(self, x):
    w = i = 0
    k = self.n
    while k:
      if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
      k >>= 1
    return i+1 bisect w = i = 0 w 0 = i = 0 i 0 k = self.n k self.n self n while k:
      if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
      k >>= 1
     k if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
       i+k <= self.n and w + self.data[i+k] <= x i+k <= self.n i+k i k self.n self n w + self.data[i+k] <= x w + self.data[i+k] w self.data[i+k] self.data self data i+k i k x w += self.data[i+k] w self.data[i+k] self.data self data i+k i k i += k i k k >>= 1 k 1 return i+1 i+1 i 1 self self x x N = I() N I() I A = list(S()) A list(S()) list S() S Q = I() Q I() I l:BIT(int_log(N,2)+1) for l in AZ for l in AZ l AZ for l in AZ l BIT(int_log(N,2)+1) BIT int_log(N,2)+1 int_log(N,2) int_log N 2 1 dic = {l:BIT(int_log(N,2)+1) for l in AZ} dic {l:BIT(int_log(N,2)+1) for l in AZ} for i in range(N):
  s = A[i]
  dic[s].add(i+1,1) i range(N) range N s = A[i] s A[i] A i dic[s].add(i+1,1) [s].add [s] dic s add i+1 i 1 1 def change(i,y):
  prev = A[i-1]
  if prev == y:
    pass
  else:
    A[i-1] = y
    dic[prev].add(i,-1)
    dic[y].add(i,1)
   change prev = A[i-1] prev A[i-1] A i-1 i 1 if prev == y:
    pass
  else:
    A[i-1] = y
    dic[prev].add(i,-1)
    dic[y].add(i,1)
   prev == y prev y A[i-1] = y A[i-1] A i-1 i 1 y dic[prev].add(i,-1) [prev].add [prev] dic prev add i -1 dic[y].add(i,1) [y].add [y] dic y add i 1 i i y y def count(x,y):
  ret = 0
  for l in AZ:
    if dic[l].sum(x-1) != dic[l].sum(y):
      ret += 1
  print(ret) count ret = 0 ret 0 for l in AZ:
    if dic[l].sum(x-1) != dic[l].sum(y):
      ret += 1
   l AZ if dic[l].sum(x-1) != dic[l].sum(y):
      ret += 1
   dic[l].sum(x-1) != dic[l].sum(y) dic[l].sum(x-1) [l].sum [l] dic l sum x-1 x 1 dic[l].sum(y) [l].sum [l] dic l sum y ret += 1 ret 1 print(ret) print ret x x y y for _ in range(Q):
  t,x,y = SL()
  if t == "1":
    change(int(x),y)
  else:
    count(int(x),int(y)) _ range(Q) range Q t,x,y = SL() t SL() SL x y if t == "1":
    change(int(x),y)
  else:
    count(int(x),int(y)) t == "1" t "1" change(int(x),y) change int(x) int x y count(int(x),int(y)) count int(x) int x int(y) int y s = A[i] A[i] s gyaku_kaijo_memo = [] [] gyaku_kaijo_memo def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM##### def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM##### gcd def IL(): return list(map(int,input().split())) def IL(): return list(map(int,input().split())) IL def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n] def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n] kaijo def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors###### def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors###### factorization Q = I() I() Q N = I() I() N t,x,y = SL() SL() t y = SL() SL() y def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog##### def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog##### base_10_to_n_without_0 def N(): print("No"); return def N(): print("No"); return N AZ = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" AZ def inv(n): return pow(n, MOD-2, MOD)

######Combination###### def inv(n): return pow(n, MOD-2, MOD)

######Combination###### inv def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
############# def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
############# int_log def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X)))) def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X)))) base_n_to_10 def count(x,y):
  ret = 0
  for l in AZ:
    if dic[l].sum(x-1) != dic[l].sum(y):
      ret += 1
  print(ret) def count(x,y):
  ret = 0
  for l in AZ:
    if dic[l].sum(x-1) != dic[l].sum(y):
      ret += 1
  print(ret) count def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT###### def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT###### SLL def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def ILL(n): return [list(map(int, input().split())) for _ in range(n)] ILL def E(): exit() def E(): exit() E def DD(arg): return defaultdict(arg)

#####Inverse##### def DD(arg): return defaultdict(arg)

#####Inverse##### DD A = list(S()) list(S()) A def P(arg): print(arg); return def P(arg): print(arg); return P def NE(): print("No"); exit()

#####Shorten##### def NE(): print("No"); exit()

#####Shorten##### NE def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount##### def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount##### lcm def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n] def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n] base_10_to_n INF = float('inf') float('inf') INF def I(): return int(input().strip()) def I(): return int(input().strip()) I def SL(): return list(map(str,input().split())) def SL(): return list(map(str,input().split())) SL def YE(): print("Yes"); exit() def YE(): print("Yes"); exit() YE def change(i,y):
  prev = A[i-1]
  if prev == y:
    pass
  else:
    A[i-1] = y
    dic[prev].add(i,-1)
    dic[y].add(i,1)
   def change(i,y):
  prev = A[i-1]
  if prev == y:
    pass
  else:
    A[i-1] = y
    dic[prev].add(i,-1)
    dic[y].add(i,1)
   change def Y(): print("Yes"); return def Y(): print("Yes"); return Y def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes###### def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes###### make_divisors MOD = 10**9+7 10**9+7 MOD def PE(arg): print(arg); exit() def PE(arg): print(arg); exit() PE def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase##### def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase##### count_bit dic = {l:BIT(int_log(N,2)+1) for l in AZ} {l:BIT(int_log(N,2)+1) for l in AZ} dic def SLs(n): return list(input().strip() for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) SLs def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n] def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n] gyaku_kaijo def S(): return input().strip() def S(): return input().strip() S kaijo_memo = [] [] kaijo_memo class BIT:
  def __init__(self, logn):
    self.n = 1<<logn
    self.data = [0]*(self.n+1)
    self.el = [0]*(self.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):
    # assert i > 0
    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 bisect(self, x):
    w = i = 0
    k = self.n
    while k:
      if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
      k >>= 1
    return i+1 class BIT:
  def __init__(self, logn):
    self.n = 1<<logn
    self.data = [0]*(self.n+1)
    self.el = [0]*(self.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):
    # assert i > 0
    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 bisect(self, x):
    w = i = 0
    k = self.n
    while k:
      if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
      k >>= 1
    return i+1 BIT def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization###### def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization###### nCr def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD##### def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD##### make_primes x,y = SL() SL() x def ILs(n): return list(int(input()) for _ in range(n)) def ILs(n): return list(int(input()) for _ in range(n)) ILs input = sys.stdin.readline sys.stdin.readline input
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
class BIT:
  def __init__(self, logn):
    self.n = 1<<logn
    self.data = [0]*(self.n+1)
    self.el = [0]*(self.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):
    # assert i > 0
    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 bisect(self, x):
    w = i = 0
    k = self.n
    while k:
      if i+k <= self.n and w + self.data[i+k] <= x:
        w += self.data[i+k]
        i += k
      k >>= 1
    return i+1

N = I()
A = list(S())
Q = I()

dic = {l:BIT(int_log(N,2)+1) for l in AZ}

for i in range(N):
  s = A[i]
  dic[s].add(i+1,1)

def change(i,y):
  prev = A[i-1]
  if prev == y:
    pass
  else:
    A[i-1] = y
    dic[prev].add(i,-1)
    dic[y].add(i,1)
  
def count(x,y):
  ret = 0
  for l in AZ:
    if dic[l].sum(x-1) != dic[l].sum(y):
      ret += 1
  print(ret)

for _ in range(Q):
  t,x,y = SL()
  if t == "1":
    change(int(x),y)
  else:
    count(int(x),int(y))
