import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[] arr = br.readLine().toCharArray(); int[] counts = new int[]{1, 0, 0, 0, 1, 0, 1, 0, 2, 1}; long total = 1; for (char c : arr) { total += counts[c - '0']; } System.out.println(Math.min(arr.length * 2 + total + 1, arr.length + (total + 1) * 2)); } }