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