#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long V;
    int brN=0,c;
    scanf("%lld", &V);
    while(V>0)
    {
        c=V%10;
        brN += c/5 + c%5/2 + c%5%2;
        V/=10;
    }
    printf("%d",brN);
}