#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,h;
	cin>>n;
	m=n%1000;
	h=n/1000;
	if(h>m){
		cout<<n;
	}else{
		cout<<m*1000+h;
	}
}
/**************************************************************
	Problem: 1631
	User: wangyiyang
	Language: C++
	Result: Accepted
	Time:6 ms
	Memory:2072 kb
****************************************************************/