I,R=input,range N=int(I()) c=[0]*10 b=[0]*40 for s in I():c[int(s)]+=1 for n in R(1000): T,m=[0]*10,n while m: T[m%10]+=1 m//=10 b[n%40]|=(sum(T)==min(N,3))*all(T[i]<=c[i]for i in R(10)) print(sum(b))