#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,x,n;
	cin>>x;
	a=x%10;
	b=x%100/10;
	c=x%1000/100;
	d=x/1000;
	n=a*1000+b*100+c*10+d;
	cout<<n;
}
/**************************************************************
	Problem: 1029
	User: xuezihong1
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/