#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,s,g,h,b,q;
	cin>>x;
	g=x%10;
	h=x/10%10;
	b=x/100%10;
	q=x/1000;
	s=g*1000+h*100+b*10+q;
	cout<<s;
}

/**************************************************************
	Problem: 1029
	User: huanghengyi
	Language: C++
	Result: Accepted
	Time:17 ms
	Memory:2072 kb
****************************************************************/