s = input() total1 = 1 total2 = 2 for c in s: if c in ("0", "4", "6", "9"): total1 += 3 total2 += 3 elif c == "8": total1 += 4 total2 += 5 else: total1 += 2 total2 += 1 print(min(total1, total2))