N = int(eval(input()))

S = eval(input())

#0なし

numlist = [""]

dp = [False] * 1000

for s in S:

    tmp = []

    for n in numlist:

        if len(n+s) == 3:

            dp[int(n+s)] = True

        if len(n+s) < 3:

            tmp.append(n+s)

    numlist.extend(tmp)

    numlist = list(set(numlist))

print((sum(dp)))
N = int(eval(input()))

S = eval(input())

X = ["{:03d}".format(i) for i in range(1000)]

# print(X)

ans = 0

for x in X:

    now = 0

    for s in S:

        if s == x[now]:

            now += 1

        if now == 3:

            ans += 1

            break

print(ans)
N = int(eval(input()))
S = eval(input())
# 0なし
numlist = [""]
dp = [False] * 1000
for s in S:
    tmp = []
    for n in numlist:
        if len(n + s) == 3:
            dp[int(n + s)] = True
        if len(n + s) < 3:
            tmp.append(n + s)
    numlist.extend(tmp)
    numlist = list(set(numlist))
print((sum(dp)))

N = int(eval(input()))
S = eval(input())
X = ["{:03d}".format(i) for i in range(1000)]
# print(X)
ans = 0
for x in X:
    now = 0
    for s in S:
        if s == x[now]:
            now += 1
        if now == 3:
            ans += 1
            break
print(ans)

-# 0なし -numlist = [""] -dp = [False] * 1000 -for s in S: -    tmp = [] -    for n in numlist: -        if len(n + s) == 3: -            dp[int(n + s)] = True -        if len(n + s) < 3: -            tmp.append(n + s) -    numlist.extend(tmp) -    numlist = list(set(numlist)) -print((sum(dp))) +X = ["{:03d}".format(i) for i in range(1000)] +# print(X) +ans = 0 +for x in X: +    now = 0 +    for s in S: +        if s == x[now]: +            now += 1 +        if now == 3: +            ans += 1 +            break +print(ans)