n=int(input())
l=list(input())
q=int(input())
bit=[[0]*(n+1) for i in range(26)]
def bit_sum(o,i):
  s=0
  while i:
    s+=bit[o][i]
    i-=i&-i
  return s
def bit_add(o,i,x):
  while i<=n:
    bit[o][i] += x
    i+=i&-i
for i in range(n):
  bit_add(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=input().split()
  b=int(b)-1
  if a=='1':
    bit_add(ord(l[b])-97,b+1,-1)
    l[b]=c
    bit_add(ord(c)-97,b+1,1)
  else:
    c=int(c)
    print(sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b))) n=int(input()) n int(input()) int input() input l=list(input()) l list(input()) list input() input q=int(input()) q int(input()) int input() input [0]*(n+1) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) [0]*(n+1) [0] 0 n+1 n 1 bit=[[0]*(n+1) for i in range(26)] bit [[0]*(n+1) for i in range(26)] def bit_sum(o,i):
  s=0
  while i:
    s+=bit[o][i]
    i-=i&-i
  return s bit_sum s=0 s 0 while i:
    s+=bit[o][i]
    i-=i&-i
   i s+=bit[o][i] s bit[o][i] [o] bit o i i-=i&-i i i&-i i -i i return s s o o i i def bit_add(o,i,x):
  while i<=n:
    bit[o][i] += x
    i+=i&-i bit_add while i<=n:
    bit[o][i] += x
    i+=i&-i i<=n i n bit[o][i] += x bit[o][i] [o] bit o i x i+=i&-i i i&-i i -i i o o i i x x for i in range(n):
  bit_add(ord(l[i])-97,i+1,1) i range(n) range n bit_add(ord(l[i])-97,i+1,1) bit_add ord(l[i])-97 ord(l[i]) ord l[i] l i 97 i+1 i 1 1 for i in range(q):
  a,b,c=input().split()
  b=int(b)-1
  if a=='1':
    bit_add(ord(l[b])-97,b+1,-1)
    l[b]=c
    bit_add(ord(c)-97,b+1,1)
  else:
    c=int(c)
    print(sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b))) i range(q) range q a,b,c=input().split() a input().split() ().split () input split b c b=int(b)-1 b int(b)-1 int(b) int b 1 if a=='1':
    bit_add(ord(l[b])-97,b+1,-1)
    l[b]=c
    bit_add(ord(c)-97,b+1,1)
  else:
    c=int(c)
    print(sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b))) a=='1' a '1' bit_add(ord(l[b])-97,b+1,-1) bit_add ord(l[b])-97 ord(l[b]) ord l[b] l b 97 b+1 b 1 -1 l[b]=c l[b] l b c bit_add(ord(c)-97,b+1,1) bit_add ord(c)-97 ord(c) ord c 97 b+1 b 1 1 c=int(c) c int(c) int c print(sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b))) print sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b)) sum 1 def bit_sum(o,i):
  s=0
  while i:
    s+=bit[o][i]
    i-=i&-i
  return s def bit_sum(o,i):
  s=0
  while i:
    s+=bit[o][i]
    i-=i&-i
  return s bit_sum b,c=input().split() input().split() b n=int(input()) int(input()) n l=list(input()) list(input()) l bit=[[0]*(n+1) for i in range(26)] [[0]*(n+1) for i in range(26)] bit c=int(c) int(c) c a,b,c=input().split() input().split() a c=input().split() input().split() c def bit_add(o,i,x):
  while i<=n:
    bit[o][i] += x
    i+=i&-i def bit_add(o,i,x):
  while i<=n:
    bit[o][i] += x
    i+=i&-i bit_add b=int(b)-1 int(b)-1 b q=int(input()) int(input()) q
n=int(input())
l=list(input())
q=int(input())
bit=[[0]*(n+1) for i in range(26)]
def bit_sum(o,i):
  s=0
  while i:
    s+=bit[o][i]
    i-=i&-i
  return s
def bit_add(o,i,x):
  while i<=n:
    bit[o][i] += x
    i+=i&-i
for i in range(n):
  bit_add(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=input().split()
  b=int(b)-1
  if a=='1':
    bit_add(ord(l[b])-97,b+1,-1)
    l[b]=c
    bit_add(ord(c)-97,b+1,1)
  else:
    c=int(c)
    print(sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b)))