#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int sum=0;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0'||s[i]=='6'||s[i]=='9')
            sum++;
        if(s[i]=='8')
            sum+=2;
    }
    cout<<sum;
    return 0;
}