def solve(n, s):

    l = {s[i]: i for i in range(n-1, -1, -1)}

    r = {s[i]: i for i in range(n)}

    S = set()

    for j in range(n):

        y = s[j]

        for x, i in list(l.items()):

            for z, k in list(r.items()):

                if i < j < k:

                    S.add(x+y+z)

    return len(S)



n = int(eval(input()))

s = eval(input())

print((solve(n, s)))
def solve(n, s):

    ans = 0

    for v in range(1000):

        p = 0

        for x in str(v).zfill(3):

            p = s.find(x, p)

            if p < 0:

                break

            p += 1

        ans += int(p > 0)

    return ans



assert solve(4, "0224") == 3

assert solve(6, "123123") == 17

assert solve(19, "3141592653589793238") == 329



n = int(eval(input()))

s = eval(input())

print((solve(n, s)))
def solve(n, s):
    l = {s[i]: i for i in range(n - 1, -1, -1)}
    r = {s[i]: i for i in range(n)}
    S = set()
    for j in range(n):
        y = s[j]
        for x, i in list(l.items()):
            for z, k in list(r.items()):
                if i < j < k:
                    S.add(x + y + z)
    return len(S)


n = int(eval(input()))
s = eval(input())
print((solve(n, s)))

def solve(n, s):
    ans = 0
    for v in range(1000):
        p = 0
        for x in str(v).zfill(3):
            p = s.find(x, p)
            if p < 0:
                break
            p += 1
        ans += int(p > 0)
    return ans


assert solve(4, "0224") == 3
assert solve(6, "123123") == 17
assert solve(19, "3141592653589793238") == 329
n = int(eval(input()))
s = eval(input())
print((solve(n, s)))

-    l = {s[i]: i for i in range(n - 1, -1, -1)} -    r = {s[i]: i for i in range(n)} -    S = set() -    for j in range(n): -        y = s[j] -        for x, i in list(l.items()): -            for z, k in list(r.items()): -                if i < j < k: -                    S.add(x + y + z) -    return len(S) +    ans = 0 +    for v in range(1000): +        p = 0 +        for x in str(v).zfill(3): +            p = s.find(x, p) +            if p < 0: +                break +            p += 1 +        ans += int(p > 0) +    return ans +assert solve(4, "0224") == 3 +assert solve(6, "123123") == 17 +assert solve(19, "3141592653589793238") == 329