#include <stdio.h>

int main()
{
  int n, j, d, s, m, mj, md, ms;
  
  scanf("%d", &n);
  
  if (n<1 || n>999 || n<100)
  {
    printf("-1\n");
    return;
  }
  
  j=n%10;
  d=(n/10)%10;
  s=n/100;
  
  ms=j;
  if (ms>d)
  {
    ms=d;
    md=j;
    if (md>s)
    {
      md=s;
      mj=j;
    }
    else
    {
      md=j;
      mj=s;
    }
  }
  else if (ms>s)
  {
    ms=s;
    md=j;
    if (md>d)
    {
      md=d;
      mj=j;
    }
    else
    {
      md=j;
      mj=d;
    }
  }
  else
  {
    ms=j;
    md=d;
    if (md>s)
    {
      md=s;
      mj=d;
    }
    else
    {
      md=d;
      mj=s;
    }
  }
  
  m=ms*100+md*10+mj;
  
  printf("%d\n", m);
  
  return 0;
}

