n=int(eval(input()))

s=eval(input())

ans=0

for aim in range(100):

  sa=str(aim)

  if aim<=9:sa="0"+sa

  cnt=0;k=-1

  for i in range(n):

    if sa[cnt]==s[i]:cnt+=1

    if cnt==2:k=i;break

  else:continue

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

print(ans)
n=int(eval(input()))

s=eval(input())

l=[[]for i in range(11)]

for i in range(n):

    d=int(s[i])

    l[d].append(i)

ans=0

le=[len(f) for f in l]

from bisect import bisect_left as bl,bisect_right as br

for i in range(0,1000):

    ss=str(i).zfill(3)



    now=-1

    for x in ss:

        c=br(l[int(x)],now)

        if c==le[int(x)]:break

        now=l[int(x)][c]

    else:



        ans+=1

print(ans)
n = int(eval(input()))
s = eval(input())
ans = 0
for aim in range(100):
    sa = str(aim)
    if aim <= 9:
        sa = "0" + sa
    cnt = 0
    k = -1
    for i in range(n):
        if sa[cnt] == s[i]:
            cnt += 1
        if cnt == 2:
            k = i
            break
    else:
        continue
    ans += len(set(list(s[k + 1 :])))
print(ans)

n = int(eval(input()))
s = eval(input())
l = [[] for i in range(11)]
for i in range(n):
    d = int(s[i])
    l[d].append(i)
ans = 0
le = [len(f) for f in l]
from bisect import bisect_left as bl, bisect_right as br

for i in range(0, 1000):
    ss = str(i).zfill(3)
    now = -1
    for x in ss:
        c = br(l[int(x)], now)
        if c == le[int(x)]:
            break
        now = l[int(x)][c]
    else:
        ans += 1
print(ans)

+l = [[] for i in range(11)] +for i in range(n): +    d = int(s[i]) +    l[d].append(i) -for aim in range(100): -    sa = str(aim) -    if aim <= 9: -        sa = "0" + sa -    cnt = 0 -    k = -1 -    for i in range(n): -        if sa[cnt] == s[i]: -            cnt += 1 -        if cnt == 2: -            k = i +le = [len(f) for f in l] +from bisect import bisect_left as bl, bisect_right as br + +for i in range(0, 1000): +    ss = str(i).zfill(3) +    now = -1 +    for x in ss: +        c = br(l[int(x)], now) +        if c == le[int(x)]: +        now = l[int(x)][c] -        continue -    ans += len(set(list(s[k + 1 :]))) +        ans += 1