import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.next(); scan.close(); int l = s.length(); int k1 = 0; for(int i = 0; i < l; i++) { char c = s.charAt(i); if(c == '1' || c == '2' || c == '3' || c == '5' || c == '7') { continue; }else if(c == '4' || c == '6' || c == '9' || c == '0') { k1++; }else { k1 += 2; } } int min = Math.min(2 * l + k1 + 1, 2 * (k1 + 1) + l); System.out.println(min); } }