#include #include using namespace std; using ll = long long; using V = vector; using P = pair; using i128 = __int128; using mint = atcoder::modint998244353; // using mint = atcoder::modint1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define Rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define UNIQUE(a) sort(all(a)), (a).erase(unique(all(a)), (a).end()) #define YES cout << "Yes" << '\n' #define NO cout << "No" << '\n' inline void Yn(bool b) { cout << (b ? "Yes" : "No") << '\n'; } template bool chmax(T& x, const U& y) { if (x < y) { x = y; return true; } return false; } template bool chmin(T& x, const U& y) { if (y < x) { x = y; return true; } return false; } const ll INF = 1e18; const int IINF = 1e9; const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, 1, -1}; void solve() { string s; cin >> s; string ans = ""; int n = s.size(); int small = -1,u = -1; rep(i,n){ if(s[i]-'0' < 4) { small = i; break; } } rep(i,small){ if(s[i] == '5') u = i; } rep(i,n){ if(s[i]-'0' > 5){ rep(j,n-i) ans.push_back('5'); break; } else if(i == small && u != -1){ rep(j,small-u) ans.pop_back(); ans.push_back('4'); rep(j,n-i) ans.push_back('5'); break; } else if(s[i]-'0' < 4){ rep(j,n-i-1) ans.push_back('5'); break; } else{ ans.push_back(s[i]); } } cout << ans << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int t = 1; //cin >> t; while (t--) solve(); }