def main():

  import sys

  n,s,_,*t=sys.stdin.buffer.read().split()

  n=int(n)

  d=[0]*n+[2**(c-97)for c in s]

  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]

  r=[]

  for q,a,b in zip(*[iter(t)]*3):

    i,s=int(a)+n-1,0

    if q<b'2':

      d[i]=2**(b[0]-97)

      while i>1:

        i//=2

        d[i]=d[i+i]|d[i-~i]

      continue

    j=int(b)+n

    while i<j:

      if i&1:

        s|=d[i]

        i+=1

      if j&1:

        j-=1

        s|=d[j]

      i//=2

      j//=2

    r+=bin(s).count('1'),

  print((' '.join(map(str,r))))

main()
def main():

  import sys

  n,s,_,*t=sys.stdin.buffer.read().split()

  n=int(n)

  d=[0]*n+[1<<c-97for c in s]

  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i+i+1]

  r=[]

  for q,a,b in zip(*[iter(t)]*3):

    i,s=int(a)+n-1,0

    if q<b'2':

      d[i]=1<<b[0]-97

      while i>1:

        i//=2

        d[i]=d[i+i]|d[i+i+1]

      continue

    j=int(b)+n

    while i<j:

      if i&1:

        s|=d[i]

        i+=1

      if j&1:

        j-=1

        s|=d[j]

      i//=2

      j//=2

    r+=bin(s).count('1'),

  print((' '.join(map(str,r))))

main()
def main():
    import sys

    n, s, _, *t = sys.stdin.buffer.read().split()
    n = int(n)
    d = [0] * n + [2 ** (c - 97) for c in s]
    for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i - ~i]
    r = []
    for q, a, b in zip(*[iter(t)] * 3):
        i, s = int(a) + n - 1, 0
        if q < b"2":
            d[i] = 2 ** (b[0] - 97)
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
            continue
        j = int(b) + n
        while i < j:
            if i & 1:
                s |= d[i]
                i += 1
            if j & 1:
                j -= 1
                s |= d[j]
            i //= 2
            j //= 2
        r += (bin(s).count("1"),)
    print((" ".join(map(str, r))))


main()

def main():
    import sys

    n, s, _, *t = sys.stdin.buffer.read().split()
    n = int(n)
    d = [0] * n + [1 << c - 97 for c in s]
    for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i + i + 1]
    r = []
    for q, a, b in zip(*[iter(t)] * 3):
        i, s = int(a) + n - 1, 0
        if q < b"2":
            d[i] = 1 << b[0] - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i + i + 1]
            continue
        j = int(b) + n
        while i < j:
            if i & 1:
                s |= d[i]
                i += 1
            if j & 1:
                j -= 1
                s |= d[j]
            i //= 2
            j //= 2
        r += (bin(s).count("1"),)
    print((" ".join(map(str, r))))


main()

-    d = [0] * n + [2 ** (c - 97) for c in s] +    d = [0] * n + [1 << c - 97 for c in s] -        d[i] = d[i + i] | d[i - ~i] +        d[i] = d[i + i] | d[i + i + 1] -            d[i] = 2 ** (b[0] - 97) +            d[i] = 1 << b[0] - 97 -                d[i] = d[i + i] | d[i - ~i] +                d[i] = d[i + i] | d[i + i + 1]