#include #include #include using namespace std; constexpr int Z = 40; void dfs(int cnt[10], int n, int a, bool f[]) { if (n == 0) { f[a%Z] = true; return; } for (int i = 0; i < 10; i++) { if (cnt[i] > 0) { cnt[i]--; dfs(cnt, n - 1, a * 10 + i, f); cnt[i]++; } } } int main() { int n; cin >> n; int cnt[10] = {0}; for (int i = 0; i < n; i++) { char c; cin >> c; cnt[c-'0']++; } for (int i = 0; i < n; i++) { cnt[i] = min(cnt[i], 3); } bool f[Z] = {false}; dfs(cnt, min(3, n), 0, f); cout << accumulate(f, f + Z, 0) << endl; return 0; }