#QHD0000006. Xóa chữ số (Removing Digits)
Xóa chữ số (Removing Digits)
Removing Digits
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Start from integer . At each step, choose a nonzero digit of the current number and subtract it. Find the minimum number of steps to reach 0.
Input
The only line contains .
Output
Print the minimum number of steps.
Subtasks
- Subtask 1 — 20 points: 1 <= n <= 100.
- Subtask 2 — 30 points: 1 <= n <= 10000.
- Subtask 3 — 50 points: 1 <= n <= 1000000.
Examples
Input
27
Output
5
Explanation
An optimal sequence is , using 5 steps.