搜索 OR next_permutation(arr, arr + len);
//#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 10;
int times[27] = {0}, ans = 0, len;
int arr[MAXN] = {0};
void dfs(int step)
{
if(step == len)
{
ans++;
for(int i = 0; i < len; i++)
cout<<char(arr[i] + 'a');
cout<<endl;
return ;
}
else
{
for(int i = 0; i < 26; i++)
{
if(times[i] > 0)
{
arr[step] = i;
times[i]--;
dfs(step + 1);
times[i]++;
}
}
}
}
int main()
{
//ios::sync_with_stdio(false);
//cin.tie(0); cout.tie(0);
cin>>len;
char a;
for(int i = 0; i < len; i++)
{
cin>>a;
times[a - 'a']++;
}
dfs(0);
cout<<ans<<endl;
return 0;
}