#include using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define ll long long const long long mod=998244353; const long long hmod=46216567629137; int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); string N; cin>>N; ll cnt=0; ll max_three=-1; rep(i,N.size()){ cnt+=N[i]-'0'; if(max_three==-1 && N[i]=='3') max_three=i; } if(max_three==-1 && cnt%3!=0){ cout<=0;i--){ if(N[i]=='0'){ N[i]='9'; } else{ N[i]--; if(N[i]=='3'){ check=1; max_three=i; } break; } } if(check==0){ cout<