#include <bits/stdc++.h>
using namespace std;
int main(){
	int len; cin >> len;
	string s; cin >> s;
	int ans = 0;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			int l = 0, r = len - 1;
			while(l < len && s[l] != i + '0') l++;
			while(r > -1 && s[r] != j + '0') r--;
			int msk = 0;
			for(int k = l + 1; k < r; k++){
				msk |= 1<<(s[k] - '0');
			}
			ans += __builtin_popcount(msk);
		}
	}
	cout << ans << endl;
	return 0;
}
