def solve():
    import sys
    input = sys.stdin.readline

    ordA = ord('a')

    N = int(input())
    Ss = input().strip()
    nos = [ord(S)-ordA for S in Ss]
    Q = int(input())

    idEle = 0
    def _binOpe(x, y):
        return x | y
    def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
    def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
    def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

    data, numPow2 = makeSegTree(N)

    As = [(1<<no) for no in nos]
    setInit(As)

    anss = []
    for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

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


solve() def solve():
    import sys
    input = sys.stdin.readline

    ordA = ord('a')

    N = int(input())
    Ss = input().strip()
    nos = [ord(S)-ordA for S in Ss]
    Q = int(input())

    idEle = 0
    def _binOpe(x, y):
        return x | y
    def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
    def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
    def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

    data, numPow2 = makeSegTree(N)

    As = [(1<<no) for no in nos]
    setInit(As)

    anss = []
    for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

    print('\n'.join(map(str, anss))) solve import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline ordA = ord('a') ordA ord('a') ord 'a' N = int(input()) N int(input()) int input() input Ss = input().strip() Ss input().strip() ().strip () input strip ord(S)-ordA for S in Ss for S in Ss S Ss for S in Ss ord(S)-ordA ord(S) ord S ordA nos = [ord(S)-ordA for S in Ss] nos [ord(S)-ordA for S in Ss] Q = int(input()) Q int(input()) int input() input idEle = 0 idEle 0 def _binOpe(x, y):
        return x | y
     _binOpe return x | y x | y x y x x y y def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
     makeSegTree numPow2 = 2 ** (numEle-1).bit_length() numPow2 2 ** (numEle-1).bit_length() 2 (numEle-1).bit_length() numEle-1).bit_length numEle-1 numEle 1 bit_length data = [idEle] * (2*numPow2) data [idEle] * (2*numPow2) [idEle] idEle 2*numPow2 2 numPow2 return data, numPow2 return data, numPow2 data numPow2 numEle numEle def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
     setInit for iST, A in enumerate(As, numPow2):
            data[iST] = A
         iST A enumerate(As, numPow2) enumerate As numPow2 data[iST] = A data[iST] data iST A for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
     iST reversed(range(1, numPow2)) reversed range(1, numPow2) range 1 numPow2 data[iST] = _binOpe(data[2*iST], data[2*iST+1]) data[iST] data iST _binOpe(data[2*iST], data[2*iST+1]) _binOpe data[2*iST] data 2*iST 2 iST data[2*iST+1] data 2*iST+1 2*iST 2 iST 1 As As def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
     _update1 iST = iA + numPow2 iST iA + numPow2 iA numPow2 data[iST] = A data[iST] data iST A iA iA A A def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
     update _update1(iA, A) _update1 iA A iST = iA + numPow2 iST iA + numPow2 iA numPow2 while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
     iST > 1 iST 1 iST >>= 1 iST 1 data[iST] = _binOpe(data[2*iST], data[2*iST+1]) data[iST] data iST _binOpe(data[2*iST], data[2*iST+1]) _binOpe data[2*iST] data 2*iST 2 iST data[2*iST+1] data 2*iST+1 2*iST 2 iST 1 iA iA A A def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

     getValue L = iSt + numPow2 L iSt + numPow2 iSt numPow2 R = iEn + numPow2 R iEn + numPow2 iEn numPow2 ans = idEle ans idEle while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
         L < R L R if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
             L & 1 L 1 ans = _binOpe(ans, data[L]) ans _binOpe(ans, data[L]) _binOpe ans data[L] data L L += 1 L 1 if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
             R & 1 R 1 R -= 1 R 1 ans = _binOpe(ans, data[R]) ans _binOpe(ans, data[R]) _binOpe ans data[R] data R L >>= 1 L 1 R >>= 1 R 1 return ans ans iSt iSt iEn iEn data, numPow2 = makeSegTree(N) data makeSegTree(N) makeSegTree N numPow2 (1<<no) for no in nos for no in nos no nos for no in nos 1<<no 1 no As = [(1<<no) for no in nos] As [(1<<no) for no in nos] setInit(As) setInit As anss = [] anss [] for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

     _ range(Q) range Q tp, v1, v2 = input().split() tp input().split() ().split () input split v1 v2 if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

     tp == '1' tp '1' pos = int(v1)-1 pos int(v1)-1 int(v1) int v1 1 c = ord(v2)-ordA c ord(v2)-ordA ord(v2) ord v2 ordA update(pos, 1<<c) update pos 1<<c 1 c L, R = int(v1)-1, int(v2)-1 L int(v1)-1 int(v1) int v1 1 R int(v2)-1 int(v2) int v2 1 v = getValue(L, R+1) v getValue(L, R+1) getValue L R+1 R 1 ans = bin(v).count('1') ans bin(v).count('1') (v).count (v) bin v count '1' anss.append(ans) anss.append anss append ans print('\n'.join(map(str, anss))) print '\n'.join(map(str, anss)) '\n'.join '\n' join map(str, anss) map str anss solve() solve def solve():
    import sys
    input = sys.stdin.readline

    ordA = ord('a')

    N = int(input())
    Ss = input().strip()
    nos = [ord(S)-ordA for S in Ss]
    Q = int(input())

    idEle = 0
    def _binOpe(x, y):
        return x | y
    def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
    def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
    def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

    data, numPow2 = makeSegTree(N)

    As = [(1<<no) for no in nos]
    setInit(As)

    anss = []
    for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

    print('\n'.join(map(str, anss))) def solve():
    import sys
    input = sys.stdin.readline

    ordA = ord('a')

    N = int(input())
    Ss = input().strip()
    nos = [ord(S)-ordA for S in Ss]
    Q = int(input())

    idEle = 0
    def _binOpe(x, y):
        return x | y
    def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
    def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
    def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

    data, numPow2 = makeSegTree(N)

    As = [(1<<no) for no in nos]
    setInit(As)

    anss = []
    for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

    print('\n'.join(map(str, anss))) solve
def solve():
    import sys
    input = sys.stdin.readline

    ordA = ord('a')

    N = int(input())
    Ss = input().strip()
    nos = [ord(S)-ordA for S in Ss]
    Q = int(input())

    idEle = 0
    def _binOpe(x, y):
        return x | y
    def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
    def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
    def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

    data, numPow2 = makeSegTree(N)

    As = [(1<<no) for no in nos]
    setInit(As)

    anss = []
    for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

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


solve()
