import std.stdio;
import std.string;

size_t lb(int[10][] arr, int n, int key) {
	long left = -1;
	long right = arr.length;

	while(right - left > 1) {
		long mid = left + (right - left) / 2;
		if (arr[mid][n] >= key) right = mid;
		else left = mid;
	}
	return right;
}

void main() {
	int n;
	scanf("%d\n", &n);
	auto s = readln.chomp;
	int[10][] lad = new int[10][n];

	foreach(j; 0..10) {
		if (j == s[0] - 48) {
			++lad[0][j];
		}
	}
	foreach(i; 1..n) {
		foreach(j; 0..10) {
			lad[i][j] = lad[i-1][j];
			if (j == s[i] - 48) {
				++lad[i][j];
			}
		}
	}
	int cnt;
	foreach(i; 0..10) {
		foreach(j; 0..10) {
			foreach(k; 0..10) {
				auto si = lb(lad, i, 1);
				if (si >= n) continue;
				auto sj = lb(lad, j, 1 + lad[si][j]);
				if (sj >= n) continue;
				auto sk = lb(lad, k, 1 + lad[sj][k]);
				if (sk < n)
					++cnt;
			}
		}
	}
	cnt.write;
}
