#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b cnt; for(auto c:s)cnt[c]++; bool titoi=true; for(auto p:cnt){ if(p.second!=2) titoi=false; if(p.second>4) return false; } if(titoi) return true; for(char head='1';head<='9';head++){ if(cnt[head]<2) continue; int unko=0; auto cp=cnt; cp[head]-=2; for(char p='1';p<='9';p++){ unko+=cp[p]/3; cp[p]%=3; } for(char p='1';p<='7';p++){ int mini=min({cp[p],cp[p+1],cp[p+2]}); cp[p]-=mini; cp[p+1]-=mini; cp[p+2]-=mini; unko+=mini; } if(unko==4) return true; } for(char head='1';head<='9';head++){ if(cnt[head]<2) continue; int unko=0; auto cp=cnt; cp[head]-=2; for(char p='1';p<='7';p++){ int mini=min({cp[p],cp[p+1],cp[p+2]}); cp[p]-=mini; cp[p+1]-=mini; cp[p+2]-=mini; unko+=mini; } for(char p='1';p<='9';p++){ unko+=cp[p]/3; cp[p]%=3; } if(unko==4) return true; } return false; } signed main(){ cin.tie(0); ios::sync_with_stdio(0); string s;cin>>s; sort(ALL(s)); if(s=="1112345678999"){ rep(i,9) cout<