#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b,h;
scanf("%d",&n);
a=n/1000;
b=n%1000;
if (b>a){
h=b*1000+a;
cout<<h<<endl;
}
else {
h=a*1000+b;
cout<<h<<endl;
}
return 0;
}
/**************************************************************
Problem: 1631
User: xiaojingxuan
Language: C++
Result: Accepted
Time:8 ms
Memory:2072 kb
****************************************************************/