import java.util.Scanner;
public class Takmicenje {
	private static Scanner input = new Scanner (System.in);
	public static void main(String[] args) {
		double v = input.nextDouble();
		int[] d = new int [3];
		d[0] = 1;
		d[1] = 2;
		d[2] = 5;
		int b = 0;
		while(v > 0);{
			double s = 0;
			double s1 = 0;
			for(int k = 0; k < 10; k++) {
				for(int i = 0; i < 3; i++) {
					s = d[i] * Math.pow(10, k);
					if(v <= s ) {
						v = v - s1;
						b++;
						break;
					}else {
						s1 = s;
					}
				}
				if(v <= s) {
					break;
				}

			}

		}
		System.out.println(b);
	}

}