#include using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; using u128 = unsigned __int128; using i128 = __int128; void solve() { std::string N; std::cin >> N; int n = (int)N.size(); std::string ans = ""; int a = -1; for(int i = 0; i < n; i ++) { int x = N[i] - '0'; if(x > 5) { for(int j = i; j < n; j ++) ans += '5'; break; } else if(x < 4) { if(a == -1) { ans = ""; for(int j = 0; j < n - 1; j ++) ans += '5'; } else { ans[a] = '4'; for(int j = a + 1; j < i; j ++) ans[j] = '5'; for(int j = i; j < n; j ++) ans += '5'; } break; } else { ans += N[i]; if(N[i] == '5') a = i; } } std::cout << ans; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int T = 1; //std::cin >> T; while (T--) { solve(); } return 0; }