let inpt = readLine()! var ans1 = inpt.count * 2 ans1 += inpt.map{ $0 }.filter{ "0469".map{$0 }.contains($0)}.count ans1 += inpt.map{ $0 }.filter{ $0 == "8"}.count * 2 ans1 += 1 var ans2 = 1 ans2 += inpt.count ans2 += inpt.map{ $0 }.filter{ "0469".map{$0 }.contains($0)}.count ans2 += inpt.map{ $0 }.filter{ $0 == "8"}.count * 2 print(min(ans1, ans2))