#include using namespace std; #define _overload3(_1, _2, _3, name, ...) name #define rep1(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define rep(...) _overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define all(x) (x).begin(),(x).end() using ll=long long; using P=pair; const ll LINF = 8e18; template bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false;} template bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false;} template ll ipow(T n, int a) {ll p = 1; rep(i,a)p*=n;return p;} template void vout(vector &v,int str = 0, int sum=0){if(sum){cout<> s; auto chk = [&](string t)->bool{ ll cnt = 0; rep(i,t.size()){ ll num = t[i] -'0'; if(num == 3)return true; cnt += num; } if(cnt%3 == 0)return true; return false; }; //文字列で1引く関数 auto subone =[&](string t)->string{ if(t == "0") return "err"; //0だけは別に処理しておく rrep(i, t.size()){ if(t[i] != '0'){ t[i]--; break; } //繰り下がり t[i] = '9'; } //先頭のゼロを削除用 ll ind = 0; while(ind + 1 < t.size() && t[ind] == '0') ind++; return t.substr(ind); }; while(chk(s))s = subone(s); cout << s << endl; return 0; }