#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,g,s,b,q,h=0;
    scanf("%d",&x);
    g=x%10;
    s=x/10%10;
    b=x/100%10;
    q=x/1000;
    h=g*1000+s*100+b*10+q;
    printf("%d",h);
    return 0;
}
/**************************************************************
	Problem: 1029
	User: binzicheng1
	Language: C++
	Result: Accepted
	Time:16 ms
	Memory:2076 kb
****************************************************************/