#include<bits/stdc++.h>
using namespace std;

int main(){
	int x,a,b,c,d;
	cin>>x;
	a=x%10*1000;
	b=x/10%10*100;
	c=x/100%10*10;
	d=x/1000%10*1;
	cout<<a+b+c+d;
	
	return 0;
}

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