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):
        # assert i > 0
        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)

n = int(input())
s = list(input())
q = int(input())
ord_a = ord("a")
queries = [tuple(input().split()) for i in range(q)]
bits = [BIT(n) for i in range(26)]
for k,v in enumerate(s,1):
  bits[ord(v)-ord_a].add(k,1)
for query,i,c in queries:
  if query == "1":
    i = int(i)
    prev = s[i-1]
    if prev != c:
      bits[ord(prev)-ord_a].add(i,-1)
      bits[ord(c)-ord_a].add(i,1)
      s[i-1] = c
  elif query == "2":
    l,r = int(i),int(c)
    res = 0
    for bit in bits:
      if bit.get(r,l-1):
        res += 1
    print(res) 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):
        # assert i > 0
        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) BIT def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
     __init__ self.n = n self.n self n n self.data = [0]*(n+1) self.data self data [0]*(n+1) [0] 0 n+1 n 1 self.el = [0]*(n+1) self.el self el [0]*(n+1) [0] 0 n+1 n 1 self self n n def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
     sum s = 0 s 0 while i > 0:
            s += self.data[i]
            i -= i & -i
         i > 0 i 0 s += self.data[i] s self.data[i] self.data self data i i -= i & -i i i & -i i -i i return s s self self i i def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
     add self.el[i] += x self.el[i] self.el self el i x while i <= self.n:
            self.data[i] += x
            i += i & -i
     i <= self.n i self.n self n self.data[i] += x self.data[i] self.data self data i x i += i & -i i i & -i i -i i self self i i x x def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i) get if j is None:
            return self.el[i]
         j is None j None return self.el[i] self.el[i] self.el self el i return self.sum(j) - self.sum(i) self.sum(j) - self.sum(i) self.sum(j) self.sum self sum j self.sum(i) self.sum self sum i self self i i j=None j None n = int(input()) n int(input()) int input() input s = list(input()) s list(input()) list input() input q = int(input()) q int(input()) int input() input ord_a = ord("a") ord_a ord("a") ord "a" tuple(input().split()) for i in range(q) for i in range(q) i range(q) range q for i in range(q) tuple(input().split()) tuple input().split() ().split () input split queries = [tuple(input().split()) for i in range(q)] queries [tuple(input().split()) for i in range(q)] BIT(n) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) BIT(n) BIT n bits = [BIT(n) for i in range(26)] bits [BIT(n) for i in range(26)] for k,v in enumerate(s,1):
  bits[ord(v)-ord_a].add(k,1) k v enumerate(s,1) enumerate s 1 bits[ord(v)-ord_a].add(k,1) [ord(v)-ord_a].add [ord(v)-ord_a] bits ord(v)-ord_a ord(v) ord v ord_a add k 1 for query,i,c in queries:
  if query == "1":
    i = int(i)
    prev = s[i-1]
    if prev != c:
      bits[ord(prev)-ord_a].add(i,-1)
      bits[ord(c)-ord_a].add(i,1)
      s[i-1] = c
  elif query == "2":
    l,r = int(i),int(c)
    res = 0
    for bit in bits:
      if bit.get(r,l-1):
        res += 1
    print(res) query i c queries if query == "1":
    i = int(i)
    prev = s[i-1]
    if prev != c:
      bits[ord(prev)-ord_a].add(i,-1)
      bits[ord(c)-ord_a].add(i,1)
      s[i-1] = c
  elif query == "2":
    l,r = int(i),int(c)
    res = 0
    for bit in bits:
      if bit.get(r,l-1):
        res += 1
    print(res) query == "1" query "1" i = int(i) i int(i) int i prev = s[i-1] prev s[i-1] s i-1 i 1 if prev != c:
      bits[ord(prev)-ord_a].add(i,-1)
      bits[ord(c)-ord_a].add(i,1)
      s[i-1] = c
   prev != c prev c bits[ord(prev)-ord_a].add(i,-1) [ord(prev)-ord_a].add [ord(prev)-ord_a] bits ord(prev)-ord_a ord(prev) ord prev ord_a add i -1 bits[ord(c)-ord_a].add(i,1) [ord(c)-ord_a].add [ord(c)-ord_a] bits ord(c)-ord_a ord(c) ord c ord_a add i 1 s[i-1] = c s[i-1] s i-1 i 1 c elif query == "2":
    l,r = int(i),int(c)
    res = 0
    for bit in bits:
      if bit.get(r,l-1):
        res += 1
    print(res) query == "2" query "2" l,r = int(i),int(c) l int(i) int i r int(c) int c res = 0 res 0 for bit in bits:
      if bit.get(r,l-1):
        res += 1
     bit bits if bit.get(r,l-1):
        res += 1
     bit.get(r,l-1) bit.get bit get r l-1 l 1 res += 1 res 1 print(res) print res i = int(i) int(i) i prev = s[i-1] s[i-1] prev s = list(input()) list(input()) s res += 1 1 res r = int(i),int(c) int(c) r queries = [tuple(input().split()) for i in range(q)] [tuple(input().split()) for i in range(q)] queries n = int(input()) int(input()) n bits = [BIT(n) for i in range(26)] [BIT(n) for i in range(26)] bits l,r = int(i),int(c) int(i) l q = int(input()) int(input()) q 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):
        # assert i > 0
        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) 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):
        # assert i > 0
        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) BIT res = 0 0 res ord_a = ord("a") ord("a") ord_a
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):
        # assert i > 0
        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)

n = int(input())
s = list(input())
q = int(input())
ord_a = ord("a")
queries = [tuple(input().split()) for i in range(q)]
bits = [BIT(n) for i in range(26)]
for k,v in enumerate(s,1):
  bits[ord(v)-ord_a].add(k,1)
for query,i,c in queries:
  if query == "1":
    i = int(i)
    prev = s[i-1]
    if prev != c:
      bits[ord(prev)-ord_a].add(i,-1)
      bits[ord(c)-ord_a].add(i,1)
      s[i-1] = c
  elif query == "2":
    l,r = int(i),int(c)
    res = 0
    for bit in bits:
      if bit.get(r,l-1):
        res += 1
    print(res)