Room Number
InterviewTime limit2sMemory limit128 MB
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.