def solve():

    N = int(eval(input()))

    S = list(eval(input()))

    right = [set() for _ in range(N)]

    for i in reversed(list(range(N - 1))): right[i] = right[i + 1] | {S[i + 1]}

    left = {S[0]}

    PIN = set()

    for i in range(1, N - 1):

        for ln in left:

            for rn in right[i]:

                p = ln + S[i] + rn

                PIN |= {p}

        left |= {S[i]}

    print((len(PIN)))



    return 0



if __name__ == "__main__":

    solve()
import sys



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    S = input().strip("\n")

    Left = [set() for _ in range(N)]

    Right = [set() for _ in range(N)]

    Left[0] |= {S[0]}

    Right[N-1] |= {S[N-1]}

    for i in range(1, N):

        Left[i] = Left[i-1] | {S[i]}

        Right[N-i-1] = Right[N-i] | {S[N-i-1]}

    used = set()

    for i in range(1, N - 1):

        mid = S[i]

        for l in Left[i-1]:

            for r in Right[i+1]:

                used |= {l + mid + r}

    print((len(used)))



    return 0



if __name__ == "__main__":

    solve()
def solve():
    N = int(eval(input()))
    S = list(eval(input()))
    right = [set() for _ in range(N)]
    for i in reversed(list(range(N - 1))):
        right[i] = right[i + 1] | {S[i + 1]}
    left = {S[0]}
    PIN = set()
    for i in range(1, N - 1):
        for ln in left:
            for rn in right[i]:
                p = ln + S[i] + rn
                PIN |= {p}
        left |= {S[i]}
    print((len(PIN)))
    return 0


if __name__ == "__main__":
    solve()

import sys


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    S = input().strip("\n")
    Left = [set() for _ in range(N)]
    Right = [set() for _ in range(N)]
    Left[0] |= {S[0]}
    Right[N - 1] |= {S[N - 1]}
    for i in range(1, N):
        Left[i] = Left[i - 1] | {S[i]}
        Right[N - i - 1] = Right[N - i] | {S[N - i - 1]}
    used = set()
    for i in range(1, N - 1):
        mid = S[i]
        for l in Left[i - 1]:
            for r in Right[i + 1]:
                used |= {l + mid + r}
    print((len(used)))
    return 0


if __name__ == "__main__":
    solve()

+import sys + + +    input = sys.stdin.readline -    S = list(eval(input())) -    right = [set() for _ in range(N)] -    for i in reversed(list(range(N - 1))): -        right[i] = right[i + 1] | {S[i + 1]} -    left = {S[0]} -    PIN = set() +    S = input().strip("\n") +    Left = [set() for _ in range(N)] +    Right = [set() for _ in range(N)] +    Left[0] |= {S[0]} +    Right[N - 1] |= {S[N - 1]} +    for i in range(1, N): +        Left[i] = Left[i - 1] | {S[i]} +        Right[N - i - 1] = Right[N - i] | {S[N - i - 1]} +    used = set() -        for ln in left: -            for rn in right[i]: -                p = ln + S[i] + rn -                PIN |= {p} -        left |= {S[i]} -    print((len(PIN))) +        mid = S[i] +        for l in Left[i - 1]: +            for r in Right[i + 1]: +                used |= {l + mid + r} +    print((len(used)))