n=int(input())
s=list(input())
q=int(input())

def ctoi(c):
  return ord(c)-97
class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [[0]*(n+1) for _ in range(26)]
  def query(self,a,i):
    r = 0
    while i > 0:
      r += self.tree[a][i]
      i -= i & -i
    return r
  def update(self,i,a,x):
    while i<=n:
      self.tree[a][i]+=x
      i+=i&(-i)
bi=Bit(n)
for i in range(n):
  bi.update(i+1,ctoi(s[i]),1)
  
for _ in range(q):
  a,b,c=input().split()
  a,b=int(a),int(b)
  if a==1 and s[b-1]!=c:
    bi.update(b,ctoi(s[b-1]),-1)
    bi.update(b,ctoi(c),1)
    s[b-1]=c
  elif a==2:
    c=int(c)
    right=[bi.query(i,c) for i in range(26)]
    left=[bi.query(i,b-1) for i in range(26)]
    ans=0
    for r,l in zip(right,left):
      if r-l>0:
        ans+=1
    print(ans) 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 def ctoi(c):
  return ord(c)-97 ctoi return ord(c)-97 ord(c)-97 ord(c) ord c 97 c c class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [[0]*(n+1) for _ in range(26)]
  def query(self,a,i):
    r = 0
    while i > 0:
      r += self.tree[a][i]
      i -= i & -i
    return r
  def update(self,i,a,x):
    while i<=n:
      self.tree[a][i]+=x
      i+=i&(-i) Bit def __init__(self, n):
    self.size = n
    self.tree = [[0]*(n+1) for _ in range(26)]
   __init__ self.size = n self.size self size n [0]*(n+1) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [0]*(n+1) [0] 0 n+1 n 1 self.tree = [[0]*(n+1) for _ in range(26)] self.tree self tree [[0]*(n+1) for _ in range(26)] self self n n def query(self,a,i):
    r = 0
    while i > 0:
      r += self.tree[a][i]
      i -= i & -i
    return r
   query r = 0 r 0 while i > 0:
      r += self.tree[a][i]
      i -= i & -i
     i > 0 i 0 r += self.tree[a][i] r self.tree[a][i] self.tree[a] self.tree self tree a i i -= i & -i i i & -i i -i i return r r self self a a i i def update(self,i,a,x):
    while i<=n:
      self.tree[a][i]+=x
      i+=i&(-i) update while i<=n:
      self.tree[a][i]+=x
      i+=i&(-i) i<=n i n self.tree[a][i]+=x self.tree[a][i] self.tree[a] self.tree self tree a i x i+=i&(-i) i i&(-i) i -i i self self i i a a x x bi=Bit(n) bi Bit(n) Bit n for i in range(n):
  bi.update(i+1,ctoi(s[i]),1)
   i range(n) range n bi.update(i+1,ctoi(s[i]),1) bi.update bi update i+1 i 1 ctoi(s[i]) ctoi s[i] s i 1 for _ in range(q):
  a,b,c=input().split()
  a,b=int(a),int(b)
  if a==1 and s[b-1]!=c:
    bi.update(b,ctoi(s[b-1]),-1)
    bi.update(b,ctoi(c),1)
    s[b-1]=c
  elif a==2:
    c=int(c)
    right=[bi.query(i,c) for i in range(26)]
    left=[bi.query(i,b-1) for i in range(26)]
    ans=0
    for r,l in zip(right,left):
      if r-l>0:
        ans+=1
    print(ans) _ range(q) range q a,b,c=input().split() a input().split() ().split () input split b c a,b=int(a),int(b) a int(a) int a b int(b) int b if a==1 and s[b-1]!=c:
    bi.update(b,ctoi(s[b-1]),-1)
    bi.update(b,ctoi(c),1)
    s[b-1]=c
  elif a==2:
    c=int(c)
    right=[bi.query(i,c) for i in range(26)]
    left=[bi.query(i,b-1) for i in range(26)]
    ans=0
    for r,l in zip(right,left):
      if r-l>0:
        ans+=1
    print(ans) a==1 and s[b-1]!=c a==1 a 1 s[b-1]!=c s[b-1] s b-1 b 1 c bi.update(b,ctoi(s[b-1]),-1) bi.update bi update b ctoi(s[b-1]) ctoi s[b-1] s b-1 b 1 -1 bi.update(b,ctoi(c),1) bi.update bi update b ctoi(c) ctoi c 1 s[b-1]=c s[b-1] s b-1 b 1 c elif a==2:
    c=int(c)
    right=[bi.query(i,c) for i in range(26)]
    left=[bi.query(i,b-1) for i in range(26)]
    ans=0
    for r,l in zip(right,left):
      if r-l>0:
        ans+=1
    print(ans) a==2 a 2 c=int(c) c int(c) int c bi.query(i,c) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) bi.query(i,c) bi.query bi query i c right=[bi.query(i,c) for i in range(26)] right [bi.query(i,c) for i in range(26)] bi.query(i,b-1) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) bi.query(i,b-1) bi.query bi query i b-1 b 1 left=[bi.query(i,b-1) for i in range(26)] left [bi.query(i,b-1) for i in range(26)] ans=0 ans 0 for r,l in zip(right,left):
      if r-l>0:
        ans+=1
     r l zip(right,left) zip right left if r-l>0:
        ans+=1
     r-l>0 r-l r l 0 ans+=1 ans 1 print(ans) print ans a,b,c=input().split() input().split() a right=[bi.query(i,c) for i in range(26)] [bi.query(i,c) for i in range(26)] right s=list(input()) list(input()) s class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [[0]*(n+1) for _ in range(26)]
  def query(self,a,i):
    r = 0
    while i > 0:
      r += self.tree[a][i]
      i -= i & -i
    return r
  def update(self,i,a,x):
    while i<=n:
      self.tree[a][i]+=x
      i+=i&(-i) class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [[0]*(n+1) for _ in range(26)]
  def query(self,a,i):
    r = 0
    while i > 0:
      r += self.tree[a][i]
      i -= i & -i
    return r
  def update(self,i,a,x):
    while i<=n:
      self.tree[a][i]+=x
      i+=i&(-i) Bit ans=0 0 ans left=[bi.query(i,b-1) for i in range(26)] [bi.query(i,b-1) for i in range(26)] left ans+=1 1 ans a,b=int(a),int(b) int(a) a c=int(c) int(c) c c=input().split() input().split() c bi=Bit(n) Bit(n) bi b,c=input().split() input().split() b q=int(input()) int(input()) q n=int(input()) int(input()) n b=int(a),int(b) int(b) b def ctoi(c):
  return ord(c)-97 def ctoi(c):
  return ord(c)-97 ctoi
n=int(input())
s=list(input())
q=int(input())

def ctoi(c):
  return ord(c)-97
class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [[0]*(n+1) for _ in range(26)]
  def query(self,a,i):
    r = 0
    while i > 0:
      r += self.tree[a][i]
      i -= i & -i
    return r
  def update(self,i,a,x):
    while i<=n:
      self.tree[a][i]+=x
      i+=i&(-i)
bi=Bit(n)
for i in range(n):
  bi.update(i+1,ctoi(s[i]),1)
  
for _ in range(q):
  a,b,c=input().split()
  a,b=int(a),int(b)
  if a==1 and s[b-1]!=c:
    bi.update(b,ctoi(s[b-1]),-1)
    bi.update(b,ctoi(c),1)
    s[b-1]=c
  elif a==2:
    c=int(c)
    right=[bi.query(i,c) for i in range(26)]
    left=[bi.query(i,b-1) for i in range(26)]
    ans=0
    for r,l in zip(right,left):
      if r-l>0:
        ans+=1
    print(ans)