s=input() def c(i):return s.count(str(i)) a=len(s) b=c(0)+c(4)+c(6)+c(8)*2+c(9)+1 print(min(a*2+b,a+b*2))