# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def read(): n = II() return (n,) def solve(n): n_num = 0 n_hole = 0 l_n = [int(i) for i in list(str(n))] for i in l_n: n_num += 1 if i in {0, 4, 6, 9}: n_hole += 1 elif i == 8: n_hole += 2 ans = n_num * 2 + n_hole + 1 return ans def main(): params = read() print(solve(*params)) if __name__ == "__main__": main()