def main():

  import sys

  input=sys.stdin.buffer.readline

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

  data=[[0]*n*2for _ in range(26)]

  def update(i,x):

    i+=n

    for d in data:

      j=i

      if d[j]:

        d[j]=0

        j//=2

        while j:

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

          j//=2

        break

    d=data[x]

    d[i]=1

    i//=2

    while i:

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

      i//=2

  def query(l,r):

    l+=n

    r+=n

    s=[0]*26

    while l<r:

      if l&1:

        for i,d in enumerate(data):

          s[i]|=d[l]

        l+=1

      if r&1:

        r-=1

        for i,d in enumerate(data):

          s[i]|=d[r]

      l//=2

      r//=2

    return sum(s)

  for i,c in enumerate(input()[:-1],n):

    data[c-97][i]=1

  for d in data:

    for i in range(n-1,0,-1):

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

  s=[]

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

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

    if q[0]>49:

      s+=query(int(a)-1,int(b)),

    else:

      update(int(a)-1,b[0]-97)

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

main()
def main():

  import sys

  input=sys.stdin.buffer.readline

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

  data=[0]*n*2

  def update(i,x):

    i+=n

    data[i]=x

    i//=2

    while i:

      data[i]=data[i*2]|data[i*2+1]

      i//=2

  def query(l,r):

    l+=n

    r+=n

    s=0

    while l<r:

      if l&1:

        s|=data[l]

        l+=1

      if r&1:

        r-=1

        s|=data[r]

      l//=2

      r//=2

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

  for i,c in enumerate(input()[:-1],n):data[i]=2**(c-97)

  for i in range(n-1,0,-1):data[i]=data[i*2]|data[i-~i]

  s=[]

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

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

    if q[0]>49:s+=query(int(a)-1,int(b)),

    else:update(int(a)-1,2**(b[0]-97))

  print(('\n'.join(map(str,s))))

main()
def main():
    import sys

    input = sys.stdin.buffer.readline
    n = int(eval(input())) + 1
    data = [[0] * n * 2 for _ in range(26)]

    def update(i, x):
        i += n
        for d in data:
            j = i
            if d[j]:
                d[j] = 0
                j //= 2
                while j:
                    d[j] = d[j + j] | d[j - ~j]
                    j //= 2
                break
        d = data[x]
        d[i] = 1
        i //= 2
        while i:
            d[i] = d[i + i] | d[i - ~i]
            i //= 2

    def query(l, r):
        l += n
        r += n
        s = [0] * 26
        while l < r:
            if l & 1:
                for i, d in enumerate(data):
                    s[i] |= d[l]
                l += 1
            if r & 1:
                r -= 1
                for i, d in enumerate(data):
                    s[i] |= d[r]
            l //= 2
            r //= 2
        return sum(s)

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


main()

def main():
    import sys

    input = sys.stdin.buffer.readline
    n = int(eval(input())) + 1
    data = [0] * n * 2

    def update(i, x):
        i += n
        data[i] = x
        i //= 2
        while i:
            data[i] = data[i * 2] | data[i * 2 + 1]
            i //= 2

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

    for i, c in enumerate(input()[:-1], n):
        data[i] = 2 ** (c - 97)
    for i in range(n - 1, 0, -1):
        data[i] = data[i * 2] | data[i - ~i]
    s = []
    for _ in range(int(eval(input()))):
        q, a, b = input().split()
        if q[0] > 49:
            s += (query(int(a) - 1, int(b)),)
        else:
            update(int(a) - 1, 2 ** (b[0] - 97))
    print(("\n".join(map(str, s))))


main()

-    data = [[0] * n * 2 for _ in range(26)] +    data = [0] * n * 2 -        for d in data: -            j = i -            if d[j]: -                d[j] = 0 -                j //= 2 -                while j: -                    d[j] = d[j + j] | d[j - ~j] -                    j //= 2 -                break -        d = data[x] -        d[i] = 1 +        data[i] = x -            d[i] = d[i + i] | d[i - ~i] +            data[i] = data[i * 2] | data[i * 2 + 1] -        s = [0] * 26 +        s = 0 -                for i, d in enumerate(data): -                    s[i] |= d[l] +                s |= data[l] -                for i, d in enumerate(data): -                    s[i] |= d[r] +                s |= data[r] -        return sum(s) +        return bin(s).count("1") -        data[c - 97][i] = 1 -    for d in data: -        for i in range(n - 1, 0, -1): -            d[i] = d[i + i] | d[i - ~i] +        data[i] = 2 ** (c - 97) +    for i in range(n - 1, 0, -1): +        data[i] = data[i * 2] | data[i - ~i] -            update(int(a) - 1, b[0] - 97) -    print((" ".join(map(str, s)))) +            update(int(a) - 1, 2 ** (b[0] - 97)) +    print(("\n".join(map(str, s))))