#include <bits/stdc++.h>
using namespace std;
const int MAXN=30010;
int n,ans,s1,s2,s3;
char c[MAXN];
int main () {
	scanf("%d%s",&n,c+1);
	for (int i=0;i<=9;i++) {
		for (int j=0;j<=9;j++) {
			for (int k=0;k<=9;k++) {
				s1=s2=s3=0;
				for (int l=1;l<=n;l++) {
					if (c[l]-'0'==k) {s3|=s2;}
					if (c[l]-'0'==j) {s2|=s1;}
					if (c[l]-'0'==i) {s1=1;}
					if (s3) {ans++;break;} 
				}
			}
		}
	}
	printf("%d\n",ans);
}