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

int main()
{
	int a,b,c,d,m;
	cin>>a;
	b=a/100;
	c=(a/10)%10;
	d=a%10;
	m=d*100+c*10+b;
	if(b<1||b>9)
		cout<<-1;
	else
		cout<<m;
	return 0;
}
