#include <iostream>
using namespace std;
int main() {
int num;
cin >> num;
int first_part = num / 1000;
int second_part = num % 1000;
if (first_part >= second_part) {
cout << num;
} else {
cout << second_part * 1000 + first_part;
}
return 0;
}
/**************************************************************
Problem: 1631
User: panjinyan
Language: C++
Result: Accepted
Time:9 ms
Memory:2072 kb
****************************************************************/