def main(): N = list(input()) count = 0 for n in N: if n in ("1","2","3","5","7"): count += 0 elif n in ("0","4","6","9"): count += 1 elif n == "8": count += 2 count += min(1+2*len(N), len(N)+2) print(count) if __name__ == "__main__": main()