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