Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar. 

The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows: 

"May the Great Beaver bless you! May your chacres open and may your third eye never turn blind from beholding the Truth! Take the magic number, subtract a digit from it (the digit must occur in the number) and get a new magic number. Repeat this operation until a magic number equals zero. The Earth will stand on Three Beavers for the time, equal to the number of subtractions you perform!"

Distinct subtraction sequences can obviously get you different number of operations. But the Smart Beaver is ready to face the worst and is asking you to count the minimum number of operations he needs to reduce the magic number to zero.


-----Input-----

The single line contains the magic integer n, 0 ≤ n.

  to get 20 points, you need to solve the problem with constraints: n ≤ 10^6 (subproblem C1);  to get 40 points, you need to solve the problem with constraints: n ≤ 10^12 (subproblems C1+C2);  to get 100 points, you need to solve the problem with constraints: n ≤ 10^18 (subproblems C1+C2+C3). 


-----Output-----

Print a single integer — the minimum number of subtractions that turns the magic number to a zero.


-----Examples-----
Input
24

Output
5


-----Note-----

In the first test sample the minimum number of operations can be reached by the following sequence of subtractions: 

 24 → 20 → 18 → 10 → 9 → 0

Difficulty: EASY

Solutions:
import functools
Maxn = 10000005

@functools.lru_cache(10000)
def dp(x, y):
	now = (x, y)
	if x < 10:
		first = 1 if x or y else 0
		return (first, x - max(x, y))
	mod = 1
	while mod <= x // 10:
		mod *= 10
	maxDig = x // mod
	part1 = dp(x % mod, max(maxDig, y))
	part2 = dp(x - x % mod + part1[1], y)
	return (part1[0] + part2[0], part2[1])

def solve():
	n = int(input())
	Ans = dp(n, 0)[0]
	print(Ans)
solve()


c = '0123456789'
F = {c[a] + c[b]: (c[10 - a + b], 1) if a > b else (c[10 - a], 2) for a in range(1, 10) for b in range(10)}
for b in range(1, 10):
	F['0' + c[b]] = ('0', 1)
F['00'] = ('0', 0)

def f(x):
	global F
	if x in F:
		return F[x]
	(a, b, y, s) = (int(x[0]), int(x[1]), x[2:], 0)
	for i in range(b, a, -1):
		(y, d) = f(c[i] + y)
		s += d
	for i in range(min(a, b) + 1):
		(y, d) = f(x[0] + y)
		s += d
	F[x] = ('9' + y, s)
	return F[x]
print(f('0' + input())[1])


memoization_table = {}

def compute_count(previous_max, rest):
	global memoization_table
	original_rest = rest
	if (previous_max, rest) in memoization_table:
		return memoization_table[previous_max, rest]
	num_digits = len(str(rest))
	if num_digits == 1:
		memoization_table[previous_max, original_rest] = (1, min(0, rest - previous_max))
		return (1, min(0, rest - previous_max))
	sum_count = 0
	while rest > 0:
		s = str(rest).zfill(num_digits)
		new_max = max(previous_max, int(s[0]))
		new_rest = int(s[1:])
		(count, leftover) = compute_count(new_max, new_rest)
		sum_count += count
		rest -= new_rest
		rest += leftover
	memoization_table[previous_max, original_rest] = (sum_count, rest)
	return (sum_count, rest)
n = int(input())
ans = 0
if n != 0:
	(ans, not_ans) = compute_count(0, n)
print(ans)


mem = {}

def compute_count(pmax, re):
	global mem
	ore = re
	if (pmax, re) in mem:
		return mem[pmax, re]
	numdig = len(str(re))
	if numdig == 1:
		mem[pmax, ore] = (1, min(0, re - pmax))
		return (1, min(0, re - pmax))
	sc = 0
	while re > 0:
		s = str(re).zfill(numdig)
		nmax = max(pmax, int(s[0]))
		newre = int(s[1:])
		(cnt, left) = compute_count(nmax, newre)
		sc += cnt
		re -= newre
		re += left
	mem[pmax, ore] = (sc, re)
	return (sc, re)
x = int(input())
if x:
	print(compute_count(0, x)[0])
else:
	print(0)