#include #define REP(i,n,N) for(int i=(n);i<(int) N;i++) #define p(s) cout<<(s)<>s; int ana=1; REP(i,0,s.size()){ if(s[i]=='0'||s[i]=='4'||s[i]=='6'||s[i]=='9'){ ana++; }else if(s[i]=='8') ana+=2; } p(min(2*ana+s.size(),2*s.size()+ana)); return 0; }