Under construction

Still being built. Things may change

Room Number

Interview

Time limit2sMemory limit128 MB

Summary
Given a room number, count how many plastic digit sets (0-9 each) are needed, treating 6 and 9 as interchangeable when flipped.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Dasom wants to put her room number on the door of her new home using plastic digits.

Plastic digits are sold in sets. Each set contains exactly one digit from 0 through 9. Given the room number N, find the minimum number of digit sets needed to make the number.

The digit 6 can be turned upside down and used as 9, and the digit 9 can be turned upside down and used as 6.

Input

The first line contains the room number N. N is a natural number between 1 and 1,000,000, inclusive.

Output

Print the minimum number of digit sets needed.

Examples4

  1. Example 1

    Input
    9999
    
    Expected output
    2
    
  2. Example 2

    Input
    122
    
    Expected output
    2
    
  3. Example 3

    Input
    12635
    
    Expected output
    1
    
  4. Example 4

    Input
    888888
    
    Expected output
    6