import java.util.Scanner; public class No509 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String N = sc.next(); String n[] = N.split(""); int ana = 0; int x[] = new int[n.length]; for(int i = 0;i < n.length;i++) { x[i] = Integer.parseInt(n[i]); } for(int i = 0;i < n.length;i++) { switch(x[i]) { case 1: case 2: case 3: case 5: case 7: break; case 0: case 4: case 6: case 9: ana += 1; break; case 8: ana += 2; } } System.out.println(Math.min(2*n.length + ana + 1, 2*(ana + 1) + n.length)); } }