#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG // []で配列外参照をするとエラーにしてくれる。上下のやつがないとTLEになるので注意 #endif #include using namespace std; // #include // using namespace atcoder; // #include // using namespace boost::multiprecision; using ll = long long; using Graph = vector>; ll INF = 2e18 + 1; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string S; int sum = 0; cin >> S; bool ok = true; for (int i = 0; i < S.size()-1; i++) { if (ok &&S[i]=='3') {S[i] = '2'; ok = false; sum += S[i]; continue; } if (!ok) { S[i] = '9'; } sum += S[i]; } S[S.size() - 1] = (sum % 3 == 0 ? '8' : '9'); cout << S << endl; }