#include<stdio.h>

int main()

{

int n,p,d,t,nb=0,max,min,sred,br=1;

scanf("%d",&n);

if (n>999 || n<100)
  {
    printf("-1");
    return -1;
  }

p=n/100;

d=(n%100)/10;

t=n%10;

max=p;

if (d>max)
  max=d;
if (t>max)
  max=t;

sred=p;

if (t<d<max || p<d<max)
  sred=d;
if (d<t<max || p<t<max)
  sred=t;

min=p;
if (d<p && d<t)
  min=d;
if (t<p && t<d)
  min=t;

/*if (max!=0){
  nb=nb+min*br;
  br=br*10;
}
if (sred!=0){
  nb=nb+sred*br;
  br*=10;
}

if (min!=0)
  nb=nb+max*br;*/

nb=nb+min*100+sred*10+max;

printf("%d\n",nb);
return	0;
}
