import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    N0 = 2**(N.bit_length())
    st = [0] * (N0*2)

    def gindex(l, r):
        L = l + N0; R = r + N0
        lm = (L // (L & -L)) // 2
        rm = (R // (R & -R)) // 2
        while L < R:
            if R <= rm:
                yield R - 1
            if L <= lm:
                yield L - 1
            L //= 2; R //= 2
        while L > 0:
            yield L - 1
            L //= 2

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += N0-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(l,r):
        l += N0
        r += N0
        ret = 0

        while l < r:
            if l % 2:
                ret |= st[l-1]
                l += 1
            if r % 2:
                r -= 1
                ret |= st[r-1]
            l //= 2 ; r //= 2

        return ret


    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt)


if __name__ == '__main__':
    main() import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    N0 = 2**(N.bit_length())
    st = [0] * (N0*2)

    def gindex(l, r):
        L = l + N0; R = r + N0
        lm = (L // (L & -L)) // 2
        rm = (R // (R & -R)) // 2
        while L < R:
            if R <= rm:
                yield R - 1
            if L <= lm:
                yield L - 1
            L //= 2; R //= 2
        while L > 0:
            yield L - 1
            L //= 2

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += N0-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(l,r):
        l += N0
        r += N0
        ret = 0

        while l < r:
            if l % 2:
                ret |= st[l-1]
                l += 1
            if r % 2:
                r -= 1
                ret |= st[r-1]
            l //= 2 ; r //= 2

        return ret


    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt) main sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**18 INF 10**18 10 18 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) NI lambda : int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline N = NI() N NI() NI N0 = 2**(N.bit_length()) N0 2**(N.bit_length()) 2 N.bit_length() N.bit_length N bit_length st = [0] * (N0*2) st [0] * (N0*2) [0] 0 N0*2 N0 2 def gindex(l, r):
        L = l + N0; R = r + N0
        lm = (L // (L & -L)) // 2
        rm = (R // (R & -R)) // 2
        while L < R:
            if R <= rm:
                yield R - 1
            if L <= lm:
                yield L - 1
            L //= 2; R //= 2
        while L > 0:
            yield L - 1
            L //= 2

     gindex L = l + N0 L l + N0 l N0 R = r + N0 R r + N0 r N0 lm = (L // (L & -L)) // 2 lm (L // (L & -L)) // 2 L // (L & -L) L L & -L L -L L 2 rm = (R // (R & -R)) // 2 rm (R // (R & -R)) // 2 R // (R & -R) R R & -R R -R R 2 while L < R:
            if R <= rm:
                yield R - 1
            if L <= lm:
                yield L - 1
            L //= 2; R //= 2
         L < R L R if R <= rm:
                yield R - 1
             R <= rm R rm yield R - 1 R - 1 R 1 if L <= lm:
                yield L - 1
             L <= lm L lm yield L - 1 L - 1 L 1 L //= 2 L 2 R //= 2 R 2 while L > 0:
            yield L - 1
            L //= 2

     L > 0 L 0 yield L - 1 L - 1 L 1 L //= 2 L 2 l l r r def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += N0-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

     update x = 2 ** (ord(s) - ord('a')) x 2 ** (ord(s) - ord('a')) 2 ord(s) - ord('a') ord(s) ord s ord('a') ord 'a' i += N0-1 i N0-1 N0 1 st[i] = x st[i] st i x while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

     i > 0 i 0 i = (i-1) // 2 i (i-1) // 2 i-1 i 1 2 st[i] = st[i*2+1] | st[i*2+2] st[i] st i st[i*2+1] | st[i*2+2] st[i*2+1] st i*2+1 i*2 i 2 1 st[i*2+2] st i*2+2 i*2 i 2 2 i i s s def query(l,r):
        l += N0
        r += N0
        ret = 0

        while l < r:
            if l % 2:
                ret |= st[l-1]
                l += 1
            if r % 2:
                r -= 1
                ret |= st[r-1]
            l //= 2 ; r //= 2

        return ret


     query l += N0 l N0 r += N0 r N0 ret = 0 ret 0 while l < r:
            if l % 2:
                ret |= st[l-1]
                l += 1
            if r % 2:
                r -= 1
                ret |= st[r-1]
            l //= 2 ; r //= 2

         l < r l r if l % 2:
                ret |= st[l-1]
                l += 1
             l % 2 l 2 ret |= st[l-1] ret st[l-1] st l-1 l 1 l += 1 l 1 if r % 2:
                r -= 1
                ret |= st[r-1]
             r % 2 r 2 r -= 1 r 1 ret |= st[r-1] ret st[r-1] st r-1 r 1 l //= 2 l 2 r //= 2 r 2 return ret ret l l r r for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
     i s enumerate(sys.stdin.readline().rstrip()) enumerate sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip update(i+1,s) update i+1 i 1 s Q = NI() Q NI() NI for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt) _ range(Q) range Q c,a,b = sys.stdin.readline().split() c sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split a b if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt) c == '1' c '1' update(int(a),b) update int(a) int a b ret = query(int(a),int(b)+1) ret query(int(a),int(b)+1) query int(a) int a int(b)+1 int(b) int b 1 cnt = 0 cnt 0 b = 1 b 1 for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
             i range(26) range 26 cnt += (b & ret) > 0 cnt (b & ret) > 0 b & ret b ret 0 b <<= 1 b 1 print(cnt) print cnt if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    N0 = 2**(N.bit_length())
    st = [0] * (N0*2)

    def gindex(l, r):
        L = l + N0; R = r + N0
        lm = (L // (L & -L)) // 2
        rm = (R // (R & -R)) // 2
        while L < R:
            if R <= rm:
                yield R - 1
            if L <= lm:
                yield L - 1
            L //= 2; R //= 2
        while L > 0:
            yield L - 1
            L //= 2

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += N0-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(l,r):
        l += N0
        r += N0
        ret = 0

        while l < r:
            if l % 2:
                ret |= st[l-1]
                l += 1
            if r % 2:
                r -= 1
                ret |= st[r-1]
            l //= 2 ; r //= 2

        return ret


    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt) def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    N0 = 2**(N.bit_length())
    st = [0] * (N0*2)

    def gindex(l, r):
        L = l + N0; R = r + N0
        lm = (L // (L & -L)) // 2
        rm = (R // (R & -R)) // 2
        while L < R:
            if R <= rm:
                yield R - 1
            if L <= lm:
                yield L - 1
            L //= 2; R //= 2
        while L > 0:
            yield L - 1
            L //= 2

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += N0-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(l,r):
        l += N0
        r += N0
        ret = 0

        while l < r:
            if l % 2:
                ret |= st[l-1]
                l += 1
            if r % 2:
                r -= 1
                ret |= st[r-1]
            l //= 2 ; r //= 2

        return ret


    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt) main
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    N0 = 2**(N.bit_length())
    st = [0] * (N0*2)

    def gindex(l, r):
        L = l + N0; R = r + N0
        lm = (L // (L & -L)) // 2
        rm = (R // (R & -R)) // 2
        while L < R:
            if R <= rm:
                yield R - 1
            if L <= lm:
                yield L - 1
            L //= 2; R //= 2
        while L > 0:
            yield L - 1
            L //= 2

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += N0-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(l,r):
        l += N0
        r += N0
        ret = 0

        while l < r:
            if l % 2:
                ret |= st[l-1]
                l += 1
            if r % 2:
                r -= 1
                ret |= st[r-1]
            l //= 2 ; r //= 2

        return ret


    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt)


if __name__ == '__main__':
    main()