Zero the Number#647

Zero the Number

1 second
256 megabytes
Medium (≈1350)

You are given a natural number . You can perform the following two operations:

1. Subtract any digit of from .

2. You can repeat the first operation on the resulting number.

Your task is to reduce the number to zero using these operations. What is the minimum number of operations required?

Input

The input contains a single integer (1 \leq n \leq 10^6).

Output

Output the minimum number of operations needed to make the number equal to zero.

Examples

In the example: 27 → 20 → 18 → 10 → 9 → 1 — the process takes a minimum of 5 steps.

Example 1

Loading
Loading