#include // #include // #include #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define YES cout<< "Yes"<< endl #define NO cout<< "No"<< endl #define Rep(i,s,n) for(int i = (int)(s); i < (int)(n); i++) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() 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; } #define UNIQUE(a) a.erase(unique(a.begin(),a.end()),a.end()) using namespace std; // using mint = atcoder::modint998244353; // using mint2 = atcoder::modint1000000007; // using namespace atcoder; using ll = long long; using V = vector; using P = pair; using i128 = __int128; void solve(){ string s; cin >> s; int n = s.size(); int u = -1, f = -1,b = -1; string ans = ""; rep(i,n){ if(s[i]-'0' < 4){ u = i; break; } } rep(i,u){ if(s[i] == 5) f = i; if(s[i]-'0' > 5) b = i; } if(u != -1 && f == -1 && b == -1){ rep(j,ans.size()) cout << ans[j]; rep(j,n-1) cout << 5; cout << endl; return; } rep(i,n){ if(s[i]-'0' > 5){ rep(j,n-i) cout << 5; cout << endl; return; } if(i == f){ rep(j,ans.size()) cout << ans[j]; cout << 4; rep(j,n-ans.size()-1)cout<< 5; cout << endl; return; } ans.push_back(s[i]); } cout << ans << endl; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int t; t = 1; //cin >> t; rep(i,t) solve(); }