n = int(eval(input()))

s = eval(input())



pins = [str(i).zfill(3) for i in range(1000)]



ans = 0

for pin in pins:

    index = -1;

    for c in pin:

      index = s.find(c, index+1);

      if (index < 0):

        break;

    if (index > 0):

      ans += 1;

      

print(ans)

n = int(eval(input()))

s = eval(input())



pins = [str(i).zfill(3) for i in range(1000)]



ans = 0

for pin in pins:

    index = -1;

    for c in pin:

      index = s.find(c, index+1);

      if (index < 0):

        break;

    else:

      ans += 1;

      

print(ans)

n = int(eval(input()))
s = eval(input())
pins = [str(i).zfill(3) for i in range(1000)]
ans = 0
for pin in pins:
    index = -1
    for c in pin:
        index = s.find(c, index + 1)
        if index < 0:
            break
    if index > 0:
        ans += 1
print(ans)

n = int(eval(input()))
s = eval(input())
pins = [str(i).zfill(3) for i in range(1000)]
ans = 0
for pin in pins:
    index = -1
    for c in pin:
        index = s.find(c, index + 1)
        if index < 0:
            break
    else:
        ans += 1
print(ans)

-    if index > 0: +    else: