This page is still under construction.

Parts of this page are still being built. What you see may change.

Odd Number Holic Hoseok

Time limit1sMemory limit512 MB

Summary
Split a number repeatedly into 2 or 3 parts, summing the parts, and track the total count of odd digits seen; find the minimum and maximum possible totals.
Level

Medium6 of 10

Topics
Dynamic programming, Recursion, Brute force, Implementation
Solved
No attempts yet

Problem

Hoseok likes odd numbers more than even numbers, because they share the same initial letter as his name. He is so fond of them that when he drives and the license plate of the car ahead is full of odd digits, he feels a certain tenderness. He wants his phone number to contain only odd digits too. Now that he is addicted to odd numbers, Hoseok wants to see as many odd digits as possible among the digits that appear while he puts his number N through a series of operations.

Given a number, Hoseok performs the following steps in one operation.

  • He writes down on paper the count of odd digits among the digits of the number.
  • If the number has one digit, he can do nothing more and stops.
  • If the number has two digits, he splits it into 2 parts, adds them, and treats the sum as the new number.
  • If the number has three or more digits, he cuts it at any positions into 3 parts, adds the three, and treats the sum as the new number.

When the operations end, Hoseok adds up all the numbers written on the paper. The resulting total is called the final value. For example, if the starting number is 82019, splitting it as below lets him see 5 odd digits, so the final value is 5.

Given the number N that Hoseok starts with, find the minimum and maximum final values he can make.

Input

The first line gives the number N that Hoseok starts with.

Output

On the first line, print the minimum and maximum final values that Hoseok can make, in that order, separated by a space.

Constraints

  • 1 ≤ N ≤ 10^9 - 1, and N is a positive integer.

Examples3

  1. Example 1

    Input
    514
    
    Expected output
    4 4
    
  2. Example 2

    Input
    82019
    
    Expected output
    4 5
    
  3. Example 3

    Input
    999999999
    
    Expected output
    11 18