CodeEff/ECCO huggingface dataset:
# Original solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(eval(input()))
S = input().rstrip()

ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    ti = 0
    for j in range(N):
        if S[j] == t[ti]:
            ti += 1
        if ti == 3:
            break
    if ti == 3:
        ans += 1

print(ans)


# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(eval(input()))
S = input().rstrip()

ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    t1 = S.find(t[0])
    if t1 == -1:
        continue
    t2 = S.find(t[1], t1+1)
    if t2 == -1:
        continue
    t3 = S.find(t[2], t2+1)
    if t3 == -1:
        continue
    ans += 1

print(ans)
# Original solution
N = int(eval(input()))
S = input().rstrip()

dp = [[[[False for _ in range(11)] for _ in range(11)]
       for _ in range(11)] for _ in range(N + 1)]

for i in range(N):
    num = int(S[i])
    for j in range(11):
        for k in range(11):
            for l in range(11):
                dp[i + 1][num][10][10] = True

                dp[i + 1][j][10][10] = dp[i][j][10][10]
                dp[i + 1][j][num][10] = dp[i][j][10][10]

                dp[i + 1][j][k][10] = dp[i][j][k][10]
                dp[i + 1][j][k][num] = dp[i][j][k][10]

                dp[i + 1][j][k][l] = dp[i][j][k][l]

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            if dp[N][i][j][k]:
                # print(i, j, k)
                ans += 1

print(ans)


# Optimized solution
N = int(eval(input()))
S = input().rstrip()

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)
# Original solution
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    N = sc.intarr()[0]
    S = sc.strarr()[0]

    count = 0

    for i in range(1000):
        # print("--------")
        lucky = format_str(i)
        Flag = 0
        for j in range(N):
            if S[j] == lucky[Flag]:
                Flag += 1
            if Flag == 3:
                count += 1
                break
    print(count)


def format_str(num):
    if num < 10:
        return "00" + str(num)
    elif num < 100:
        return "0" + str(num)
    else:
        return str(num)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()


# Optimized solution
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    _ = sc.intarr()[0]
    S = sc.strarr()[0]

    count = 0

    for i in range(1000):
        # print("--------")
        lucky = format_str(i)
        first = S.find(lucky[0])
        third = S.rfind(lucky[2])

        if first == -1 or third == -1:
            continue
        elif first < third:
            if lucky[1] in S[first + 1:third]:
                count += 1
    print(count)


def format_str(num):
    if num < 10:
        return "00" + str(num)
    elif num < 100:
        return "0" + str(num)
    else:
        return str(num)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()
# Original solution
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

anslist = []
ans = 0

for i in range(1000):
    if i < 10:
        chk = '00' + str(i)
    elif i < 100:
        chk = '0' + str(i)
    else:
        chk = str(i)

    for j in range(len(s)):
        if s[j] == chk[0]:
            for k in range(j+1, len(s)):
                if s[k] == chk[1]:
                    for l in range(k+1, len(s)):
                        if s[l] == chk[2]:
                            # print(chk)
                            anslist.append(chk)
            continue
ans = len(set(anslist))
print(ans)

# Optimized solution
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    x = s.find(i[0])
    y = s.find(i[1], x+1)
    z = s.find(i[2], y+1)
    if x != -1 and y != -1 and z != -1:
        ans += 1
print(ans)
# Original solution
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()


# Optimized solution
#三井住友2019 D
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    cnt = 0
    for i in range(0, 10):
        for j in range(0, 10):
            for k in range(0, 10):
                st1 = S.find(str(i))
                if st1 ==-1:
                    continue
                
                st2 = S[st1+1:].find(str(j))
                if st2 ==-1:
                    continue
              
                st3 = S[st1+st2+2:].find(str(k))
                if st3 ==-1:
                    continue
                #print(st1,st2,st3, i,j,k)
                cnt +=1
    print(cnt)


                    
    
   
    
if __name__=='__main__':
    main()
# Original solution
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


n = I()
s = S()

ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    t_index = 0
    for s_index in range(n):
        if s[s_index] == t[t_index]:
            t_index += 1
            if t_index == 3:
                break
    if t_index == 3:
        ans += 1
print(ans)


# Optimized solution
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
s = S()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if s.find(num[0]) == -1:
        continue
    s1 = s[s.find(num[0])+1:]
    if s1.find(num[1]) == -1:
        continue
    s2 = s1[s1.find(num[1])+1:]
    if s2.find(num[2]) == -1:
        continue
    ans+=1
print(ans)
# Original solution
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
s = S()
cnt = 0
for i in range(10 ** 3):
    flag = 0
    for j in range(n):
        for k in range(3):
            if flag == k and str(i).zfill(3)[k] == s[j]:
                flag += 1
                break
        if flag == 3:
            cnt += 1
            break


print(cnt)

# Optimized solution
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
s = S()
cnt = 0
ans = set()
one_digit_set = set()
two_digit_set = set()
for i in range(n):
    for two_d in two_digit_set:
        ans.add(s[i] + two_d)
    for one_d in one_digit_set:
        two_digit_set.add(s[i] + one_d)
    one_digit_set.add(s[i])


print((len(ans)))
# Original solution
import sys
input = sys.stdin.readline
lists = ['{0:03d}'.format(i) for i in range(1000)]
import re
def check(target, a):
    ans = re.search(a, target)
    if ans == None:
        return None
    else:
        return target[ans.start()+1:]

def print_ans(N, S):
    """Test Case
    >>> print_ans(4, "0224")
    3
    >>> print_ans(6, "123123")
    17
    >>> print_ans(19, "3141592653589793238")
    329
    """
    # s = set()
    # for i in range(N):
    #     for k in range(i+1,N):
    #         for l in range(k+1, N):
    #             s.add(S[i] + S[k] + S[l])
    # print(len(s))
    ans = 0
    for a in lists:
        tmp = S
        for i in range(3):
            tmp = check(tmp, a[i])
            if tmp == None:
                break
        if tmp != None:
            ans += 1
    print(ans)


    # print(check('123','4'))


    
if __name__ == '__main__':
    N = int(input().rstrip())
    S = input().rstrip()
    print_ans(N, S)


# Optimized solution
import sys
input = sys.stdin.readline
lists = ['{0:03d}'.format(i) for i in range(1000)]
import re
def check(target, a):
    ans = re.search(a, target)
    if ans == None:
        return None
    else:
        return target[ans.start()+1:]

def print_ans(N, S):
    """Test Case
    >>> print_ans(4, "0224")
    3
    >>> print_ans(6, "123123")
    17
    >>> print_ans(19, "3141592653589793238")
    329
    """
    ans = 0
    for a in lists:
        tmp = S
        for i in range(3):
            tmp = check(tmp, a[i])
            if tmp == None:
                break
        if tmp != None:
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    N = int(input().rstrip())
    S = input().rstrip()
    print_ans(N, S)
# Original solution
import sys
sys.setrecursionlimit(10 ** 9)

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

# 上限は1000
N = ri()
S = list(rs())
answer = set()

for i in range(len(S)-2):
    se2 = set()
    for j in range(i+1, len(S)-1):
        if j in se2:
            continue
        se2.add(j)
        se = set(S[j+1:])
        x = S[i]
        y = S[j]
        for z in se:
            answer.add((x, y, z))

print((len(answer)))

# Optimized solution
import sys
sys.setrecursionlimit(10 ** 9)

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

# 上限は1000
N = ri()
S = list(rs())
answer = set()
se1 = set()
for i in range(len(S)-2):
    x = S[i]
    if x in se1:
        continue
    se1.add(x)
    se2 = set()
    for j in range(i+1, len(S)-1):
        y = S[j]
        if y in se2:
            continue
        se2.add(y)
        se = set(S[j+1:])
        for z in se:
            answer.add((x, y, z))

print((len(answer)))
# Original solution
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

import re

n = ni()
s = ns()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            pattern = ".*" + str(i) + ".*" + str(j) + ".*" + str(k) + ".*"
            reptn = re.compile(pattern)
            if re.search(reptn, s):
                cnt += 1

print(cnt)


# Optimized solution
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

import re

n = ni()
s = ns()
cnt = 0
cand = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            stri = str(i)
            strj = str(j)
            strk = str(k)
            first = False
            second = False
            for si in s:
                if si == strk and first and second:
                    cnt += 1
                    break
                elif si == strj and first:
                    second = True
                elif si == stri:
                    first = True

print(cnt)
# Original solution
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for p in range(1000):
        pattern = str(p).zfill(3)
        key = 0
        cnt = 0
        for n in pattern:
            for i in range(key,N):
                if S[i] == n:
                    key = i+1
                    cnt += 1
                    break
        if cnt == 3:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for p in range(1000):
        pattern = str(p).zfill(3)
        cnt = 0
        T = S
        for n in pattern:
            i = T.find(n)
            if i != -1:
                T = T[i+1:]
                cnt += 1
        if cnt == 3:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
N = int(eval(input()))
S = input().strip()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if int(S[n])==cur[ind]:
                    ind += 1
                    if ind==3:break
            if ind==3:
                cnt += 1
print(cnt)

# Optimized solution
N = int(eval(input()))
S = list(map(int,list(input().strip())))
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if S[n]==cur[ind]:
                    ind += 1
                    if ind==3:
                        cnt += 1
                        break
print(cnt)
# Original solution
N = int(eval(input()))
S = input().strip()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            flag = 0
            for n in range(N):
                if flag==0 and S[n]==str(i):
                    flag = 1
                elif flag==1 and S[n]==str(j):
                    flag = 2
                elif flag==2 and S[n]==str(k):
                    flag = 3
                    break
            if flag==3:
                cnt += 1
print(cnt)

# Optimized solution
def chk(x):
    cur = 0
    cnt = 0
    while cur<N:
        if S[cur]==str(x[cnt]):
            cnt += 1
            if cnt==3:
                break
        cur += 1
    if cnt==3:
        return 1
    else:
        return 0

N = int(eval(input()))
S = input().strip()
cnt = 0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            cnt += chk((i,j,k))
print(cnt)
# Original solution
import sys
from itertools import combinations

input = sys.stdin.readline


def main():
    # 種類
    N = int(eval(input()))
    S = input().strip()
    print((len(set(combinations(S, 3)))))


if __name__ == "__main__":
    main()


# Optimized solution
import sys
from itertools import combinations

input = sys.stdin.readline


def check_num(text):
    cnt = 0
    for i in range(10):
        index = text.find(str(i))
        if index != -1:
            cnt += 1
    return cnt


def main():
    # 種類
    # N = int(input())
    # S = input().strip()
    S = sum(str(i) for i in range(10))
    for i in range(10):
        index = S.find(str(i))
        if index != -1:
            a = check_num(S[index:])
    # 10個の数字
    # 最大1000件
    # 0-9:0-9:0-9
    # print(len(set(combinations(S, 3))))


def hoge():
    N = int(eval(input()))
    S = input().strip()
    count = 0
    for x in range(10):
        xindex = S.find(str(x))
        if xindex == -1:
            continue
        for y in range(10):
            yindex = S[xindex + 1 :].find(str(y))
            if yindex == -1:
                continue
            for z in range(10):
                zindex = S[xindex + 1 :][yindex + 1 :].find(str(z))
                if zindex == -1:
                    continue
                count += 1
    print(count)


if __name__ == "__main__":
    hoge()
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = read().rstrip().decode()
cnt = 0
for i in range(1000):
    num = ''
    if i < 100:
        num += '0'
        if i < 10:
            num += '0'
    num += str(i)
    index = 0
    for ss in s:
        if ss == num[index]:
            index += 1
            if index == 3:
                cnt += 1
                break
print(cnt)


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = read().rstrip().decode()
cnt = 0
for i in range(1000):
    num = str(i).zfill(3)
    idx = -1
    for m in num:
        idx = s.find(m, idx + 1)
        if idx == -1:
            break
    else:
        cnt += 1
print(cnt)
# Original solution
import sys
readline = sys.stdin.readline

n = int(readline())
s = readline().rstrip()

from collections import deque
q = deque([])

ss = set(s)

for i in ss:
    q.append(["",0,str(i)])

ans = 0
while q:
    num, ind, target = q.popleft()
    #print(num, ind, target)
    while ind < len(s):
        if s[ind] == target: #s[ind]が０から9の中のどれかを見てる
            break
        ind += 1
    else:
        continue
    num += target
    if len(num) == 3:
        ans += 1
        continue
    for i in range(10):
        q.append([num, ind +1, str(i)]) #出現した数字に関するキューを追加（例：一回目は024）

print(ans)

# Optimized solution
import sys
readline = sys.stdin.readline

n = int(readline())
s = readline().rstrip()

from collections import deque
q = deque([])

ss = set(s)

for i in ss:
    q.append(["",0,str(i)])

ans = 0
while q:
    num, ind, target = q.popleft()
    #print(num, ind, target)
    while ind < len(s):
        if s[ind] == target: #s[ind]が０から9の中のどれかを見てる
            break
        ind += 1
    else:
        continue
    num += target
    if len(num) == 3:
        ans += 1
        continue
    sss = set(s[ind+1:])
    for i in sss:
        q.append([num, ind +1, str(i)]) #出現した数字に関するキューを追加（例：一回目は024）

print(ans)
# Original solution
import sys
input = sys.stdin.readline
import copy

N=int(eval(input()))
S=input().strip()

SUB={""}
ANS=set()

for s in S:
    NSUB=copy.deepcopy(SUB)
    for t in SUB:
        x=t+s
        if len(x)<=2:
            NSUB.add(x)
        else:
            ANS.add(x)

    SUB=NSUB

print((len(ANS)))

# Optimized solution
import sys
input = sys.stdin.readline

N=int(eval(input()))
S=input().strip()

SUB={""}
ANS=set()

for s in S:
    N=set()
    for t in SUB:
        x=t+s
        if len(x)<=2:
            N.add(x)
        else:
            ANS.add(x)

    SUB|=N

print((len(ANS)))
# Original solution
_,s=open(0)
x,y,z=eval('set(),'*3)
for c in s[:-1]:
  for t in y:z.add(t+c)
  for t in x:y.add(t+c)
  x.add(c)
print((len(z)))

# Optimized solution
_,s=open(0)
x,y,z=eval('set(),'*3)
for c in s[:-1]:
  z|={t+c for t in y}
  y|={t+c for t in x}
  x|={c}
print((len(z)))
# Original solution
from collections import*
_,s=open(0)
dp=defaultdict(bool)
for c in s[:-1]:
  for i in range(100):
    j=str(i).zfill(2)
    dp[j+c]|=dp[j]
  for i in range(10):
    j=str(i)
    dp[j+c]|=dp[j]
  dp[c]=True
print((sum(dp[str(i).zfill(3)]for i in range(1000))))

# Optimized solution
from collections import*
_,s=open(0)
dp=defaultdict(bool)
d1=[str(i)for i in range(10)]
d2=[str(i).zfill(2)for i in range(100)]
for c in s[:-1]:
  for i in d2:
    dp[i+c]|=dp[i]
  for i in d1:
    dp[i+c]|=dp[i]
  dp[c]=True
print((sum(dp[str(i).zfill(3)]for i in range(1000))))
# Original solution
import re

N = int(eval(input()))
S = input().strip()

count = 0
for c1 in range(10):
	for c2 in range(10):
		for c3 in range(10):
			if re.search("{}.*{}.*{}".format(c1, c2, c3), S):
				count += 1
print(count)



# Optimized solution
import re

N = int(eval(input()))
S = [int(c) for c in input().strip()]
length = len(S)

count = 0
for c1 in range(10):
	index1 = 0
	while index1 < length:
		if S[index1] == c1:
			index1 += 1
			break
		index1 += 1
	if index1 < length:
		for c2 in range(10):
			index2 = index1
			while index2 < length:
				if S[index2] == c2:
					index2 += 1
					break
				index2 += 1
			if index2 < length:
				for c3 in range(10):
					index3 = index2
					while index3 < length:
						if S[index3] == c3:
							count += 1
							break
						index3 += 1
print(count)