#include <stdio.h>

int main(){

	int b, j, d, s, minC, maxC, srC;

	scanf("%i", &b);

	if(b<100 || b>999){
		printf("-1\n");
 		return 1;
	}
	j=b%10;
	d=(b/10)%10;
	s=b/100;

	minC=(j<d)?j:d;
	minC=(minC<s)?minC:s;

	maxC=(j>d)?j:d;
	maxC=(maxC>s)? maxC:s;

	if((minC==j && maxC==d) || (minC==d && maxC==j))
		srC=s;
	else if((minC==j && maxC==s) || (minC==s && maxC==j))
		srC=d;
	else
		srC=j;

	printf("%i\n", b=minC*100 + srC*10 + maxC);

	return 0;

}
