#!/usr/bin/env python3

n = int(eval(input()))

s = eval(input())

s = [int(i) for i in s]

c = 0

for i in range(10):

    for j in range(10):

        if i in s:

            t = s[s.index(i) + 1:]

            if j in t:

                c += len(set(t[t.index(j) + 1:]))

print(c)

#!/usr/bin/env python3

n = int(eval(input()))

s = eval(input())

c = 0

for i in range(10):

    for j in range(10):

        a = s.find(str(i))

        if a > -1:

            b = s.find(str(j), a + 1)

            if b > -1:

                c += len(set(s[b + 1:]))

print(c)

#!/usr/bin/env python3
n = int(eval(input()))
s = eval(input())
s = [int(i) for i in s]
c = 0
for i in range(10):
    for j in range(10):
        if i in s:
            t = s[s.index(i) + 1 :]
            if j in t:
                c += len(set(t[t.index(j) + 1 :]))
print(c)

#!/usr/bin/env python3
n = int(eval(input()))
s = eval(input())
c = 0
for i in range(10):
    for j in range(10):
        a = s.find(str(i))
        if a > -1:
            b = s.find(str(j), a + 1)
            if b > -1:
                c += len(set(s[b + 1 :]))
print(c)

-s = [int(i) for i in s] -        if i in s: -            t = s[s.index(i) + 1 :] -            if j in t: -                c += len(set(t[t.index(j) + 1 :])) +        a = s.find(str(i)) +        if a > -1: +            b = s.find(str(j), a + 1) +            if b > -1: +                c += len(set(s[b + 1 :]))