#include <iostream>
#include <map>
using namespace std;

map<char,int> count;
string str;
int maxstack;
void cp(){
	if(str.length()>=maxstack){
		cout<<str<<"\n";
		return;
	}
	for(auto i:count){
		if(i.second>0){
			str.push_back(i.first);
			count[i.first]--;
			cp();
			str.pop_back();
			count[i.first]++;
		}
	}
}

int main() {
	// your code goes here
	string input;
	cin>>input;
	maxstack = input.length();
	for(int i=0;i<input.length();i++)count[input[i]]++;
	cp();
	return 0;
}