n = input() c = 0 p = len(n) for i in n: if i == "8": c += 2 elif i == "0" or i == "4" or i == "6" or i == "9": c += 1 p += (c + 1) * 2 print(p)