class Segment_tree():
    def __init__(self, n, s):
        self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        self.key = dict()
        self.k = 1
        for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
        self.inf = pow(2, 32)
        self.n = n
        self.s = s
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
        self.size -= 1
        self.N -= 1
        self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n)
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

    def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = self.key[x]
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r


n = int(input())
s = input()
segment = Segment_tree(n, s)
q = int(input())
N = 1
while N < n:
  N *= 2
for i in range(q):
    quer = [x for x in input().split()]
    if quer[0] == "1":
        i, c = int(quer[1]), quer[2]
        segment.update(i, c)
    else:
        l, r = int(quer[1]), int(quer[2])
        key = segment.find(l-1, r, 0, 0, N)
        ans = 0
        for i in range(26):
            if (key>>i)&1:
                ans += 1
        print(ans) class Segment_tree():
    def __init__(self, n, s):
        self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        self.key = dict()
        self.k = 1
        for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
        self.inf = pow(2, 32)
        self.n = n
        self.s = s
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
        self.size -= 1
        self.N -= 1
        self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n)
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

    def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = self.key[x]
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r Segment_tree def __init__(self, n, s):
        self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        self.key = dict()
        self.k = 1
        for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
        self.inf = pow(2, 32)
        self.n = n
        self.s = s
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
        self.size -= 1
        self.N -= 1
        self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n)
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

     __init__ self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] self.alphabet_list self alphabet_list ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" self.key = dict() self.key self key dict() dict self.k = 1 self.k self k 1 for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
         value self.alphabet_list self alphabet_list self.key[value] = self.k self.key[value] self.key self key value self.k self k self.k *= 2 self.k self k 2 self.inf = pow(2, 32) self.inf self inf pow(2, 32) pow 2 32 self.n = n self.n self n n self.s = s self.s self s s self.N = 1 self.N self N 1 while self.N < self.n:
            self.N *= 2
         self.N < self.n self.N self N self.n self n self.N *= 2 self.N self N 2 self.size = self.N * 2 self.size self size self.N * 2 self.N self N 2 self.size -= 1 self.size self size 1 self.N -= 1 self.N self N 1 self.key[self.s[i]] for i in range(self.n) for i in range(self.n) i range(self.n) range self.n self n for i in range(self.n) self.key[self.s[i]] self.key self key self.s[i] self.s self s i self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n) self.segment self segment [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n) [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] [0]*(self.N) [0] 0 self.N self N [self.key[self.s[i]] for i in range(self.n)] [0]*(self.size-self.N-self.n) [0] 0 self.size-self.N-self.n self.size-self.N self.size self size self.N self N self.n self n for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

     i range(self.N-1, -1, -1) range self.N-1 self.N self N 1 -1 -1 self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2] self.segment[i] self.segment self segment i self.segment[2*i+1]|self.segment[2*i+2] self.segment[2*i+1] self.segment self segment 2*i+1 2*i 2 i 1 self.segment[2*i+2] self.segment self segment 2*i+2 2*i 2 i 2 self self n n s s def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = self.key[x]
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
     update i += (self.N-1) i self.N-1 self.N self N 1 self.segment[i] = self.key[x] self.segment[i] self.segment self segment i self.key[x] self.key self key x while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
     i > 0 i 0 i = (i-1)//2 i (i-1)//2 i-1 i 1 2 self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2] self.segment[i] self.segment self segment i self.segment[2*i+1]|self.segment[2*i+2] self.segment[2*i+1] self.segment self segment 2*i+1 2*i 2 i 1 self.segment[2*i+2] self.segment self segment 2*i+2 2*i 2 i 2 self self i i x x def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r find if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r r <= a or b <= l r <= a r a b <= l b l return 0 0 elif a <= l and r <= b:
            return self.segment[k]
         a <= l and r <= b a <= l a l r <= b r b return self.segment[k] self.segment[k] self.segment self segment k find_l = self.find(a, b, 2*k+1, l, (l+r)//2) find_l self.find(a, b, 2*k+1, l, (l+r)//2) self.find self find a b 2*k+1 2*k 2 k 1 l (l+r)//2 l+r l r 2 find_r = self.find(a, b, 2*k+2, (l+r)//2, r) find_r self.find(a, b, 2*k+2, (l+r)//2, r) self.find self find a b 2*k+2 2*k 2 k 2 (l+r)//2 l+r l r 2 r return find_l|find_r find_l|find_r find_l find_r self self a a b b k k l l r r n = int(input()) n int(input()) int input() input s = input() s input() input segment = Segment_tree(n, s) segment Segment_tree(n, s) Segment_tree n s q = int(input()) q int(input()) int input() input N = 1 N 1 while N < n:
  N *= 2 N < n N n N *= 2 N 2 for i in range(q):
    quer = [x for x in input().split()]
    if quer[0] == "1":
        i, c = int(quer[1]), quer[2]
        segment.update(i, c)
    else:
        l, r = int(quer[1]), int(quer[2])
        key = segment.find(l-1, r, 0, 0, N)
        ans = 0
        for i in range(26):
            if (key>>i)&1:
                ans += 1
        print(ans) i range(q) range q x for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() x quer = [x for x in input().split()] quer [x for x in input().split()] if quer[0] == "1":
        i, c = int(quer[1]), quer[2]
        segment.update(i, c)
    else:
        l, r = int(quer[1]), int(quer[2])
        key = segment.find(l-1, r, 0, 0, N)
        ans = 0
        for i in range(26):
            if (key>>i)&1:
                ans += 1
        print(ans) quer[0] == "1" quer[0] quer 0 "1" i, c = int(quer[1]), quer[2] i int(quer[1]) int quer[1] quer 1 c quer[2] quer 2 segment.update(i, c) segment.update segment update i c l, r = int(quer[1]), int(quer[2]) l int(quer[1]) int quer[1] quer 1 r int(quer[2]) int quer[2] quer 2 key = segment.find(l-1, r, 0, 0, N) key segment.find(l-1, r, 0, 0, N) segment.find segment find l-1 l 1 r 0 0 N ans = 0 ans 0 for i in range(26):
            if (key>>i)&1:
                ans += 1
         i range(26) range 26 if (key>>i)&1:
                ans += 1
         (key>>i)&1 key>>i key i 1 ans += 1 ans 1 print(ans) print ans class Segment_tree():
    def __init__(self, n, s):
        self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        self.key = dict()
        self.k = 1
        for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
        self.inf = pow(2, 32)
        self.n = n
        self.s = s
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
        self.size -= 1
        self.N -= 1
        self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n)
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

    def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = self.key[x]
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r class Segment_tree():
    def __init__(self, n, s):
        self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        self.key = dict()
        self.k = 1
        for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
        self.inf = pow(2, 32)
        self.n = n
        self.s = s
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
        self.size -= 1
        self.N -= 1
        self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n)
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

    def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = self.key[x]
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r Segment_tree N = 1 1 N key = segment.find(l-1, r, 0, 0, N) segment.find(l-1, r, 0, 0, N) key q = int(input()) int(input()) q r = int(quer[1]), int(quer[2]) int(quer[2]) r segment = Segment_tree(n, s) Segment_tree(n, s) segment n = int(input()) int(input()) n i, c = int(quer[1]), quer[2] int(quer[1]) i s = input() input() s ans = 0 0 ans ans += 1 1 ans c = int(quer[1]), quer[2] quer[2] c l, r = int(quer[1]), int(quer[2]) int(quer[1]) l N *= 2 2 N quer = [x for x in input().split()] [x for x in input().split()] quer
class Segment_tree():
    def __init__(self, n, s):
        self.alphabet_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        self.key = dict()
        self.k = 1
        for value in self.alphabet_list:
            self.key[value] = self.k
            self.k *= 2
        self.inf = pow(2, 32)
        self.n = n
        self.s = s
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2
        self.size -= 1
        self.N -= 1
        self.segment = [0]*(self.N) + [self.key[self.s[i]] for i in range(self.n)] + [0]*(self.size-self.N-self.n)
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]

    def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = self.key[x]
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.segment[2*i+1]|self.segment[2*i+2]
        
    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            return find_l|find_r


n = int(input())
s = input()
segment = Segment_tree(n, s)
q = int(input())
N = 1
while N < n:
  N *= 2
for i in range(q):
    quer = [x for x in input().split()]
    if quer[0] == "1":
        i, c = int(quer[1]), quer[2]
        segment.update(i, c)
    else:
        l, r = int(quer[1]), int(quer[2])
        key = segment.find(l-1, r, 0, 0, N)
        ans = 0
        for i in range(26):
            if (key>>i)&1:
                ans += 1
        print(ans)