#include <stdio.h>

int main() {
    char n;
    int count=0;
    while(scanf("%c",&n)!=EOF){
        if (n=='0'||n=='6'||n=='9') {
            count++;
        }else if (n=='8') {
            count+=2;
        }
    }
    printf("%d",count);
    return 0;
}