f=input

n,l,q=int(f()),list(f()),int(f())

B=[[0]*-~n for i in range(26)]

def S(o,i):

  s=0

  while i: s+=B[o][i]; i-=i&-i

  return s

def A(o,i,x):

  while i<=n: B[o][i]+=x; i+=i&-i

for i in range(n): A(ord(l[i])-97,i+1,1)

for i in range(q):

  a,b,c=f().split(); b=int(b)

  if a>'1': print((sum(1 for o in range(26) if S(o,int(c))-S(o,b-1))))

  else: A(ord(l[b-1])-97,b,-1); l[b-1]=c; A(ord(c)-97,b,1)
f=input

n,s,q=int(f()),list(f()),int(f())

d={chr(97+i):[] for i in range(26)}

for i in range(n):

  d[s[i]]+=[i]

from bisect import *

for i in range(q):

  a,b,c=f().split()

  b=int(b)-1

  if a=='1':

    if s[b]==c: continue

    d[s[b]].pop(bisect(d[s[b]],b)-1)

    s[b]=c

    insort(d[c],b)

  else:

    t=0

    for l in list(d.values()):

      m=bisect(l,b-1)

      if m<len(l) and l[m]<int(c): t+=1

    print(t)
f = input
n, l, q = int(f()), list(f()), int(f())
B = [[0] * -~n for i in range(26)]


def S(o, i):
    s = 0
    while i:
        s += B[o][i]
        i -= i & -i
    return s


def A(o, i, x):
    while i <= n:
        B[o][i] += x
        i += i & -i


for i in range(n):
    A(ord(l[i]) - 97, i + 1, 1)
for i in range(q):
    a, b, c = f().split()
    b = int(b)
    if a > "1":
        print((sum(1 for o in range(26) if S(o, int(c)) - S(o, b - 1))))
    else:
        A(ord(l[b - 1]) - 97, b, -1)
        l[b - 1] = c
        A(ord(c) - 97, b, 1)

f = input
n, s, q = int(f()), list(f()), int(f())
d = {chr(97 + i): [] for i in range(26)}
for i in range(n):
    d[s[i]] += [i]
from bisect import *

for i in range(q):
    a, b, c = f().split()
    b = int(b) - 1
    if a == "1":
        if s[b] == c:
            continue
        d[s[b]].pop(bisect(d[s[b]], b) - 1)
        s[b] = c
        insort(d[c], b)
    else:
        t = 0
        for l in list(d.values()):
            m = bisect(l, b - 1)
            if m < len(l) and l[m] < int(c):
                t += 1
        print(t)

-n, l, q = int(f()), list(f()), int(f()) -B = [[0] * -~n for i in range(26)] +n, s, q = int(f()), list(f()), int(f()) +d = {chr(97 + i): [] for i in range(26)} +for i in range(n): +    d[s[i]] += [i] +from bisect import * - -def S(o, i): -    s = 0 -    while i: -        s += B[o][i] -        i -= i & -i -    return s - - -def A(o, i, x): -    while i <= n: -        B[o][i] += x -        i += i & -i - - -for i in range(n): -    A(ord(l[i]) - 97, i + 1, 1) -    b = int(b) -    if a > "1": -        print((sum(1 for o in range(26) if S(o, int(c)) - S(o, b - 1)))) +    b = int(b) - 1 +    if a == "1": +        if s[b] == c: +            continue +        d[s[b]].pop(bisect(d[s[b]], b) - 1) +        s[b] = c +        insort(d[c], b) -        A(ord(l[b - 1]) - 97, b, -1) -        l[b - 1] = c -        A(ord(c) - 97, b, 1) +        t = 0 +        for l in list(d.values()): +            m = bisect(l, b - 1) +            if m < len(l) and l[m] < int(c): +                t += 1 +        print(t)