N = int(eval(input()))

S = list(eval(input()))

n = 0

for i in range(1000):

  ps = "%03d"%(i)

  s = S

  is_ok = True

  for j in list(ps):

    if j in s: s = s[s.index(j)+1:]

    else:

      is_ok = False

      break

  if is_ok: n+=1

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

S = eval(input())

n = 0

for i in range(1000):

  ps_i = "%03d"%(i)

  s = S

  ps_i_ok = True

  for j in ps_i:

    if j in s: s = s[s.index(j)+1:]

    else:

      ps_i_ok = False

      break

  if ps_i_ok: n+=1

print(n)
N = int(eval(input()))
S = list(eval(input()))
n = 0
for i in range(1000):
    ps = "%03d" % (i)
    s = S
    is_ok = True
    for j in list(ps):
        if j in s:
            s = s[s.index(j) + 1 :]
        else:
            is_ok = False
            break
    if is_ok:
        n += 1
print(n)

N = int(eval(input()))
S = eval(input())
n = 0
for i in range(1000):
    ps_i = "%03d" % (i)
    s = S
    ps_i_ok = True
    for j in ps_i:
        if j in s:
            s = s[s.index(j) + 1 :]
        else:
            ps_i_ok = False
            break
    if ps_i_ok:
        n += 1
print(n)

-S = list(eval(input())) +S = eval(input()) -    ps = "%03d" % (i) +    ps_i = "%03d" % (i) -    is_ok = True -    for j in list(ps): +    ps_i_ok = True +    for j in ps_i: -            is_ok = False +            ps_i_ok = False -    if is_ok: +    if ps_i_ok: