s=input() O=sum([s.count(x) for x in [x for x in "0469"]]) B=s.count("8") I=len(s)-O-B J=I-B-1 if I>B else 0 print(1+O*3+I*2+B*4-J)