import sys

input = sys.stdin.readline

N = int(eval(input()))

S = list(eval(input()))[: -1]

Q = int(eval(input()))



class BIT:

  def __init__(self, n):

    self.n = n

    self.data = [0] * (n + 1)

    self.el = [0] * (n + 1)

  def sum(self, i):

    s = 0

    while i > 0:

      s += self.data[i]

      i -= i & -i

    return s

  def add(self, i, x):

    self.el[i] += x

    while i <= self.n:

      self.data[i] += x

      i += i & -i

  def get(self, i, j = None):

    if j is None:

      return self.el[i]

    return self.sum(j) - self.sum(i)



fwks = [BIT(N + 1) for _ in range(26)]

a = ord("a")

for i in range(N):

  j = ord(S[i]) - a

  #print(j)

  fwks[j].add(i + 1, 1)

for _ in range(Q):

  q, x, y = input().split()

  q = int(q)

  if q == 1:

    x = int(x)

    for i in range(26):

      if fwks[i].get(x): fwks[i].add(x, -1)

    fwks[ord(y) - a].add(x, 1)

  else:

    x = int(x)

    y = int(y)

    res = 0

    #print(x, y)

    for i in range(26):

      res += fwks[i].get(x - 1, y) > 0

    print(res)
import sys

input = sys.stdin.readline

N = int(eval(input()))

S = list([ord(x) - ord("a") for x in list(eval(input()))[: -1]])



class BIT:

  def __init__(self, n):

    self.n = n

    self.data = [0] * (n + 1)

    self.el = [0] * (n + 1)

  def sum(self, i):

    s = 0

    while i > 0:

      s += self.data[i]

      i -= i & -i

    return s

  def add(self, i, x):

    self.el[i] += x

    while i <= self.n:

      self.data[i] += x

      i += i & -i

  def get(self, i, j = None):

    if j is None:

      return self.el[i]

    return self.sum(j) - self.sum(i)

  def lowerbound(self, s):

    x = 0

    y = 0

    for i in range(self.n.bit_length(), -1, -1):

      k = x + (1 << i)

      if k <= self.n and (y + self.data[k] < s):

        y += self.data[k]

        x += 1 << i

    return x + 1



fwk = [BIT(N) for _ in range(26)]

for i in range(N): fwk[S[i]].add(i + 1, 1)

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

  q, x, y = input().split()

  if q == "1":

    x = int(x)

    y = ord(y) - ord("a")

    fwk[S[x - 1]].add(x, -1)

    fwk[y].add(x, 1)

    S[x - 1] = y

  else:

    x = int(x)

    y = int(y)

    res = 0

    for i in range(26): res += fwk[i].get(x - 1, y) > 0

    print(res)
import sys

input = sys.stdin.readline
N = int(eval(input()))
S = list(eval(input()))[:-1]
Q = int(eval(input()))


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.el = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


fwks = [BIT(N + 1) for _ in range(26)]
a = ord("a")
for i in range(N):
    j = ord(S[i]) - a
    # print(j)
    fwks[j].add(i + 1, 1)
for _ in range(Q):
    q, x, y = input().split()
    q = int(q)
    if q == 1:
        x = int(x)
        for i in range(26):
            if fwks[i].get(x):
                fwks[i].add(x, -1)
        fwks[ord(y) - a].add(x, 1)
    else:
        x = int(x)
        y = int(y)
        res = 0
        # print(x, y)
        for i in range(26):
            res += fwks[i].get(x - 1, y) > 0
        print(res)

import sys

input = sys.stdin.readline
N = int(eval(input()))
S = list([ord(x) - ord("a") for x in list(eval(input()))[:-1]])


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.el = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

    def lowerbound(self, s):
        x = 0
        y = 0
        for i in range(self.n.bit_length(), -1, -1):
            k = x + (1 << i)
            if k <= self.n and (y + self.data[k] < s):
                y += self.data[k]
                x += 1 << i
        return x + 1


fwk = [BIT(N) for _ in range(26)]
for i in range(N):
    fwk[S[i]].add(i + 1, 1)
for _ in range(int(eval(input()))):
    q, x, y = input().split()
    if q == "1":
        x = int(x)
        y = ord(y) - ord("a")
        fwk[S[x - 1]].add(x, -1)
        fwk[y].add(x, 1)
        S[x - 1] = y
    else:
        x = int(x)
        y = int(y)
        res = 0
        for i in range(26):
            res += fwk[i].get(x - 1, y) > 0
        print(res)

-S = list(eval(input()))[:-1] -Q = int(eval(input())) +S = list([ord(x) - ord("a") for x in list(eval(input()))[:-1]]) +    def lowerbound(self, s): +        x = 0 +        y = 0 +        for i in range(self.n.bit_length(), -1, -1): +            k = x + (1 << i) +            if k <= self.n and (y + self.data[k] < s): +                y += self.data[k] +                x += 1 << i +        return x + 1 -fwks = [BIT(N + 1) for _ in range(26)] -a = ord("a") + +fwk = [BIT(N) for _ in range(26)] -    j = ord(S[i]) - a -    # print(j) -    fwks[j].add(i + 1, 1) -for _ in range(Q): +    fwk[S[i]].add(i + 1, 1) +for _ in range(int(eval(input()))): -    q = int(q) -    if q == 1: +    if q == "1": -        for i in range(26): -            if fwks[i].get(x): -                fwks[i].add(x, -1) -        fwks[ord(y) - a].add(x, 1) +        y = ord(y) - ord("a") +        fwk[S[x - 1]].add(x, -1) +        fwk[y].add(x, 1) +        S[x - 1] = y -        # print(x, y) -            res += fwks[i].get(x - 1, y) > 0 +            res += fwk[i].get(x - 1, y) > 0