#include #include #include #include using namespace std; typedef pair P; int memo[1LL<<12]; int main(){ int64_t N; int L=0; cin>>N; int a[12]; while(N){ a[L++]=N%10; N/=10; } int ans=0; vector V3,V6,V9; if(L>=3){ int comb=(1<<3)-1; int ans=0; while(comb<(1<>1)|y; } } if(L>=6){ for(int i=0;i=9){ for(auto v3:V3){ for(auto v6:V6){ if(v3&v6) continue; int sum=memo[v3]+memo[v6]; memo[v3|v6]=max(memo[v3|v6],sum); V9.push_back(v3|v6); ans=max(sum,ans); } } } if(L==12){ for(auto v3:V3){ for(auto v9:V9){ if(v3&v9)continue; int sum=memo[v3]+memo[v9]; memo[v3|v9]=max(memo[v3|v9],sum); ans=max(sum,ans); } } } cout<