#include using namespace std; typedef long long ll; typedef pair pii; typedef pair ppii; typedef pair pipi; typedef pair pll; typedef pair plpl; typedef tuple tl; ll mod=1000000007; ll mod2=998244353; ll inf=1000000000000000000; #define rep(i,m,n) for(int i=m;i=m;i--) ll lmax(ll a,ll b){ if(a v,ll c){ if(v.size()==0)return true; ll cnt[10];fill(cnt,cnt+10,0); rep(i,0,v.size())cnt[v[i]]++; ll u=v[0]; vector w=v; if(cnt[u]>=3){ rep(i,0,3){ rep(j,0,w.size()){ if(w[j]==u){ w.erase(w.begin()+j); break; } } } bool jud=dfs(w,c); if(jud)return true; } w=v; if(cnt[u]>=2&&c==0){ rep(i,0,2){ rep(j,0,w.size()){ if(w[j]==u){ w.erase(w.begin()+j); break; } } } bool jud=dfs(w,c+1); if(jud)return true; } w=v; if(cnt[u]>=1&&u<=7){ if(cnt[u+1]>=1&&cnt[u+2]>=1){ rep(i,u,u+3){ rep(j,0,w.size()){ if(w[j]==i){ w.erase(w.begin()+j); break; } } } bool jud=dfs(w,c); if(jud)return true; } } return false; } int main(){ vector v; string s;cin>>s; rep(i,0,13)v.push_back(s[i]-'0'); ll cn[10]; fill(cn,cn+10,0); rep(i,0,13)cn[v[i]]++; rep(i,1,10){ if(cn[i]==4)continue; ll sum=0; rep(j,1,10){ if(cn[j]==2)sum++; } if(sum==6&&cn[i]==1){ cout< w=v; w.push_back(i); sort(w.begin(),w.end()); bool jud=dfs(w,0); if(jud)cout<