#include #include #include using namespace std; using ll = long long; int main(void){ string s; cin >> s; int n=s.size(); int five=n+1; string pre, aft; for(int i=0; i'5'){five=i; break;} if(s[i]<'4'){five=i+1; break;} } if(five==n+1){ cout << s << endl; return 0; } for(int i=five; i=0; i--)if(s[i]=='5'){f=i; break;} if(f==-1)for(int i=1; i<=r; i++) pre+='5'; else{ for(int i=0; i<=r; i++){ if(i==f) pre+='4'; else pre+=(i