#include using namespace std; int main(){ string s;cin>>s;int m = 0; for(int i = 0; s.size() > i; i++){ if(s[i] == '8')m+=2; if(s[i] == '0' || s[i] == '4' || s[i] == '6' || s[i] == '9')m++; } cout << min(s.size()*2+1+m,(1+m)*2+s.size()) << endl; }