# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN



import sys





def main():

    N = int(eval(input()))  # 桁数

    S = str(eval(input()))



    ans = set()



    digit1 = set()



    for i in range(0, N - 2):

        if S[i] in digit1:

            continue

        digit1.add(S[i])

        digit2 = set()



        for j in range(i + 1, N - 1):

            if S[j] in digit2:

                continue

            digit2.add(S[j])

            digit3 = set()

            for k in range(j + 1, N):

                if len(digit3) == 10:

                    break

                code = S[i] + S[j] + S[k]

                ans.add(code)



    print((len(ans)))





if __name__ == '__main__':

    main()

# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN



import sys



N = int(eval(input()))

S = str(eval(input()))



ans = 0

for i in range(10):

    code1 = S.find(str(i))

    if code1 == -1:

        continue

    for j in range(10):

        code2 = S.find(str(j), code1 + 1)

        if code2 == -1:

            continue

        for k in range(10):

            code3 = S.find(str(k), code2 + 1)

            if code3 != -1:

                ans += 1



print(ans)

# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN
import sys


def main():
    N = int(eval(input()))  # 桁数
    S = str(eval(input()))
    ans = set()
    digit1 = set()
    for i in range(0, N - 2):
        if S[i] in digit1:
            continue
        digit1.add(S[i])
        digit2 = set()
        for j in range(i + 1, N - 1):
            if S[j] in digit2:
                continue
            digit2.add(S[j])
            digit3 = set()
            for k in range(j + 1, N):
                if len(digit3) == 10:
                    break
                code = S[i] + S[j] + S[k]
                ans.add(code)
    print((len(ans)))


if __name__ == "__main__":
    main()

# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN
import sys

N = int(eval(input()))
S = str(eval(input()))
ans = 0
for i in range(10):
    code1 = S.find(str(i))
    if code1 == -1:
        continue
    for j in range(10):
        code2 = S.find(str(j), code1 + 1)
        if code2 == -1:
            continue
        for k in range(10):
            code3 = S.find(str(k), code2 + 1)
            if code3 != -1:
                ans += 1
print(ans)

- -def main(): -    N = int(eval(input()))  # 桁数 -    S = str(eval(input())) -    ans = set() -    digit1 = set() -    for i in range(0, N - 2): -        if S[i] in digit1: +N = int(eval(input())) +S = str(eval(input())) +ans = 0 +for i in range(10): +    code1 = S.find(str(i)) +    if code1 == -1: +        continue +    for j in range(10): +        code2 = S.find(str(j), code1 + 1) +        if code2 == -1: -        digit1.add(S[i]) -        digit2 = set() -        for j in range(i + 1, N - 1): -            if S[j] in digit2: -                continue -            digit2.add(S[j]) -            digit3 = set() -            for k in range(j + 1, N): -                if len(digit3) == 10: -                    break -                code = S[i] + S[j] + S[k] -                ans.add(code) -    print((len(ans))) - - -if __name__ == "__main__": -    main() +        for k in range(10): +            code3 = S.find(str(k), code2 + 1) +            if code3 != -1: +                ans += 1 +print(ans)