Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 0
for a in range(10):
    ai = 0
    while ai < n:
        if s[ai] == str(a):
            break
        else:
            ai += 1
    if ai == n:
        continue
    for b in range(10):
        bi = ai + 1
        while bi < n:
            if s[bi] == str(b):
                break
            else:
                bi += 1
        if bi == n:
            continue
        for c in range(10):
            ci = bi + 1
            while ci < n:
                if s[ci] == str(c):
                    break
                else:
                    ci += 1
            if ci == n:
                continue
            else:
                ans += 1

print(ans)
exit(0)


Fixed submission:
n = int(input())
s = input()

t = [set() for _ in range(n)]
t[-1] = {int(s[-1])}

for i in range(1, n):
    base = t[n - i].copy()
    base.add(int(s[n - i - 1]))
    t[n - i - 1] = base

ans = 0
for a in range(10):
    ai = 0

    if a not in t[ai]:
        continue

    while ai < n:
        if s[ai] == str(a):
            break
        else:
            ai += 1
    if ai >= n - 2:
        continue
    for b in range(10):
        bi = ai + 1

        if b not in t[bi]:
            continue

        while bi < n:
            if s[bi] == str(b):
                break
            else:
                bi += 1
        if bi >= n - 1:
            continue
        for c in range(10):
            ci = bi + 1

            if c not in t[ci]:
                continue

            while ci < n:
                if s[ci] == str(c):
                    break
                else:
                    ci += 1
            if ci == n:
                continue
            else:
                ans += 1

print(ans)
exit(0)


x = int(input())
dp = [False for _ in range(x + 1)]
dp[0] = True
for item in [100, 101, 102, 103, 104, 105]:
    for i in range(x + 1):
        if i - item >= 0:
            if dp[i - item]:
                dp[i] = True

print(1 if dp[x] else 0)
exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            left = 0
            for i in range(n):
                if left == 0 and int(s[i]) == a:
                    left = 1
                elif left == 1 and int(s[i]) == b:
                    left = 2
                elif left == 2 and int(s[i]) == c:
                    left = 3
                if left == 3:
                    ans += 1
                    break


print(ans)
exit(0)


Fixed submission:
n = int(input())
s = input()

t = [set() for _ in range(n)]
t[-1] = {int(s[-1])}

for i in range(1, n):
    base = t[n - i].copy()
    base.add(int(s[n - i - 1]))
    t[n - i - 1] = base

ans = 0
for a in range(10):
    ai = 0

    if a not in t[ai]:
        continue

    while ai < n:
        if s[ai] == str(a):
            break
        else:
            ai += 1
    if ai >= n - 2:
        continue
    for b in range(10):
        bi = ai + 1

        if b not in t[bi]:
            continue

        while bi < n:
            if s[bi] == str(b):
                break
            else:
                bi += 1
        if bi >= n - 1:
            continue
        for c in range(10):
            ci = bi + 1

            if c not in t[ci]:
                continue

            while ci < n:
                if s[ci] == str(c):
                    break
                else:
                    ci += 1
            if ci == n:
                continue
            else:
                ans += 1

print(ans)
exit(0)


x = int(input())
dp = [False for _ in range(x + 1)]
dp[0] = True
for item in [100, 101, 102, 103, 104, 105]:
    for i in range(x + 1):
        if i - item >= 0:
            if dp[i - item]:
                dp[i] = True

print(1 if dp[x] else 0)
exit(0)