N = input() hole = 0 for i in range(len(N)): n = int(N[i]) if n == 8: hole += 2 elif n == 0 or n == 4 or n == 6 or n == 9: hole += 1 print(min(len(N)*2+hole+1, (hole+1)*2+len(N)))