### BUGGY CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = list(input())


al = set()

dp = [[[0 for k in range(10)] for i in range(10)] for j in range(10)]
co = 1
kkk = a[0]+a[1]+a[2]
dp[int(a[0])][int(a[1])][int(a[2])] = 1
al.add(kkk)
for i in range(3,n):
    j = int(a[i])
    ap = []
    for ppp in al:
        aaa = ppp
        m,mm,mmm = int(aaa[0]),int(aaa[1]),int(aaa[2])
        if not dp[m][mm][j]:
            dp[m][mm][j] = 1
            co += 1
            ap.append(str(m)+str(mm)+str(j))
        if not dp[m][mmm][j]:
            dp[m][mmm][j] = 1
            co += 1
            ap.append(str(m)+str(mmm)+str(j))
        if not dp[mm][mmm][j]:
            dp[mm][mmm][j] = 1
            co += 1
            ap.append(str(mm)+str(mmm)+str(j))
            
    for j in ap:
        al.add(j)

print(co)


### FIXED CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = list(input())


al = set()

dp = [[[0 for k in range(10)] for i in range(10)] for j in range(10)]


kkk = [[0 for j in range(10)]for i in range(n)]
count = 0
for i in range(n):
    k = int(a[i])
    if i == 0:
        kkk[i][k] += 1
    else:
        for j in range(10):
            if k == j:
                kkk[i][j] += kkk[i-1][j] + 1
            else:
                kkk[i][j] += kkk[i-1][j]

for i in range(1,n-1):
    e = int(a[i])
    ae = []
    for pl in range(10):
        if kkk[i-1][pl] > 0:
            ae.append(pl)
    for pl in range(10):
        if kkk[-1][pl] - kkk[i][pl] > 0:
            for pp in ae:
                if not dp[pp][e][pl]:
                    count += 1
                    dp[pp][e][pl] += 1
                    


print(count)