#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,x;
	cin>>x;
	a=x%10;
	b=x/10%10;
	c=x/100%10;
	d=x/1000;
	x=a*1000+b*100+c*10+d*1;
	cout<<x;



	return 0;
}
/**************************************************************
	Problem: 1029
	User: linyuhang
	Language: C++
	Result: Accepted
	Time:10 ms
	Memory:2072 kb
****************************************************************/