#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool num[15] = { false };
ll n,used[15],ans=0;
string s;
void check()
{
for (int i = 1; i <= n; i++)
if (used[i] != s[i - 1] - '0') return;
cout << ans << endl;
exit(-1);
}
void dfs(int x) {
if (x > n) {
ans++;
check();
return;
}
for (int i = 1; i <= n; i++) {
if (num[i] == false) {
num[i] = true;
used[x] = i;
dfs(x + 1);
num[i] = false;
}
}
}
int main() {
cin >> n;
cin >> s;
dfs(1);
return 0;
}