#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int64_t a;
    cin>>a;
    int rez=0;
    while(a){
        int c = a%10; a/=10;
        rez += c/5 + (c%5)/2 + ((c%5)%2);
    }
    cout<<rez<<endl;
    return 0;
}