#include <iostream>
using namespace std;
class DescendNUM{
private:
int n;
int a[5];
public:
DescendNUM(int x );
void decompose();
void dsort();
void show();
};
DescendNUM::DescendNUM(int x = 0)
{
n = x;
}
void DescendNUM::decompose()
{
a[0] = n/10000;
a[1] = (n/1000) % 10;
a[2] = (n/100)%10;
a[3] = (n/10)%10;
a[4] = n%10;
}
void DescendNUM::dsort()
{
int i;
int j;
int temp;
for (i = 0; i < 5; i++)
{
for (j = 0; j <5-i; j++)
{
if (a[j] < a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
}
void DescendNUM::show()
{
cout <<n<<endl;
int i;
for (i = 0; i < 5; i++)
{
cout<<a[i];
}
}
int main()
{
int m;
cin >>m;
DescendNUM num(m);
num.decompose();
num.dsort();
num.show();
return 0;
}
using namespace std;
class DescendNUM{
private:
int n;
int a[5];
public:
DescendNUM(int x );
void decompose();
void dsort();
void show();
};
DescendNUM::DescendNUM(int x = 0)
{
n = x;
}
void DescendNUM::decompose()
{
a[0] = n/10000;
a[1] = (n/1000) % 10;
a[2] = (n/100)%10;
a[3] = (n/10)%10;
a[4] = n%10;
}
void DescendNUM::dsort()
{
int i;
int j;
int temp;
for (i = 0; i < 5; i++)
{
for (j = 0; j <5-i; j++)
{
if (a[j] < a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
}
void DescendNUM::show()
{
cout <<n<<endl;
int i;
for (i = 0; i < 5; i++)
{
cout<<a[i];
}
}
int main()
{
int m;
cin >>m;
DescendNUM num(m);
num.decompose();
num.dsort();
num.show();
return 0;
}