#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a;
b=a/1000;
c=a/1000%1000;
if(c>b){
d=c*1000+b;
}else{
h=b*1000+c;
}
cout<<h;
}
/**************************************************************
Problem: 1631
User: toughuatao1
Language: C++
Result: Compile Error
****************************************************************/