n=int(eval(input()))+1

d=[0]*n*2

def update(i,x):

  i+=n

  d[i]=x

  while i//2:

    i//=2

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

def query(l,r):

  l+=n

  r+=n

  s=0

  while l<r:

    if l&1:

      s|=d[l]

      l+=1

    if r&1:

      r-=1

      s|=d[r]

    l//=2

    r//=2

  return bin(s).count('1')

for i,c in enumerate(eval(input()),n):d[i]=1<<ord(c)-97

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

for _ in range(int(eval(input()))):

  q,a,b=input().split()

  if q>'1':print((query(int(a)-1,int(b))))

  else:update(int(a)-1,1<<ord(b)-97)
n,s,_,*t=open(0).read().split()

n=int(n)

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

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

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

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

  if'2'>q:

    d[i]=1<<ord(b)-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

  print((bin(s).count('1')))
n = int(eval(input())) + 1
d = [0] * n * 2


def update(i, x):
    i += n
    d[i] = x
    while i // 2:
        i //= 2
        d[i] = d[i + i] | d[i - ~i]


def query(l, r):
    l += n
    r += n
    s = 0
    while l < r:
        if l & 1:
            s |= d[l]
            l += 1
        if r & 1:
            r -= 1
            s |= d[r]
        l //= 2
        r //= 2
    return bin(s).count("1")


for i, c in enumerate(eval(input()), n):
    d[i] = 1 << ord(c) - 97
for i in range(n - 1, 0, -1):
    d[i] = d[i + i] | d[i - ~i]
for _ in range(int(eval(input()))):
    q, a, b = input().split()
    if q > "1":
        print((query(int(a) - 1, int(b))))
    else:
        update(int(a) - 1, 1 << ord(b) - 97)

n, s, _, *t = open(0).read().split()
n = int(n)
d = [0] * n + [1 << ord(c) - 97 for c in s]
for i in range(n - 1, 0, -1):
    d[i] = d[i + i] | d[i - ~i]
for q, a, b in zip(*[iter(t)] * 3):
    i, s = int(a) + n - 1, 0
    if "2" > q:
        d[i] = 1 << ord(b) - 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
    print((bin(s).count("1")))

-n = int(eval(input())) + 1 -d = [0] * n * 2 - - -def update(i, x): -    i += n -    d[i] = x -    while i // 2: -        i //= 2 -        d[i] = d[i + i] | d[i - ~i] - - -def query(l, r): -    l += n -    r += n -    s = 0 -    while l < r: -        if l & 1: -            s |= d[l] -            l += 1 -        if r & 1: -            r -= 1 -            s |= d[r] -        l //= 2 -        r //= 2 -    return bin(s).count("1") - - -for i, c in enumerate(eval(input()), n): -    d[i] = 1 << ord(c) - 97 +n, s, _, *t = open(0).read().split() +n = int(n) +d = [0] * n + [1 << ord(c) - 97 for c in s] -for _ in range(int(eval(input()))): -    q, a, b = input().split() -    if q > "1": -        print((query(int(a) - 1, int(b)))) -    else: -        update(int(a) - 1, 1 << ord(b) - 97) +for q, a, b in zip(*[iter(t)] * 3): +    i, s = int(a) + n - 1, 0 +    if "2" > q: +        d[i] = 1 << ord(b) - 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 +    print((bin(s).count("1")))