n = input() l = len(n) ans = 2 * l + 1 for i in range(l): if n[i] in ['0', '4', '6', '9']: ans += 1 elif n[i] == '8': ans += 2 print(ans)