import sys

input = sys.stdin.readline

# sys.setrecursionlimit(100000)





def main():

    N = int(eval(input()))

    S = input().rstrip()

    ans = 0

    for i in range(1000):

        i = str(i).zfill(3)

        prev = -1

        for s in i:

            pos = S.find(s, prev + 1)

            if pos > prev:

                prev = pos

            else:

                break

        else:

            ans += 1

    print(ans)





if __name__ == "__main__":

    main()
n = int(eval(input()))

s = eval(input())



top_used = set()

used = set()

ans = 0

for i in range(n - 1):

    if int(s[i]) in top_used:

        continue

    top_used.add(int(s[i]))

    for j in range(i + 1, n):

        top = s[i] + s[j]

        if top not in used:

            ans += len(set(s[j + 1:]))

            used.add(top)





print(ans)

import sys

input = sys.stdin.readline
# sys.setrecursionlimit(100000)
def main():
    N = int(eval(input()))
    S = input().rstrip()
    ans = 0
    for i in range(1000):
        i = str(i).zfill(3)
        prev = -1
        for s in i:
            pos = S.find(s, prev + 1)
            if pos > prev:
                prev = pos
            else:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

n = int(eval(input()))
s = eval(input())
top_used = set()
used = set()
ans = 0
for i in range(n - 1):
    if int(s[i]) in top_used:
        continue
    top_used.add(int(s[i]))
    for j in range(i + 1, n):
        top = s[i] + s[j]
        if top not in used:
            ans += len(set(s[j + 1 :]))
            used.add(top)
print(ans)

-import sys - -input = sys.stdin.readline -# sys.setrecursionlimit(100000) -def main(): -    N = int(eval(input())) -    S = input().rstrip() -    ans = 0 -    for i in range(1000): -        i = str(i).zfill(3) -        prev = -1 -        for s in i: -            pos = S.find(s, prev + 1) -            if pos > prev: -                prev = pos -            else: -                break -        else: -            ans += 1 -    print(ans) - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +s = eval(input()) +top_used = set() +used = set() +ans = 0 +for i in range(n - 1): +    if int(s[i]) in top_used: +        continue +    top_used.add(int(s[i])) +    for j in range(i + 1, n): +        top = s[i] + s[j] +        if top not in used: +            ans += len(set(s[j + 1 :])) +            used.add(top) +print(ans)