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: interview

Starter code:

Solutions:
start = input()
counter = 0
sInt = int(start)
while sInt!=0:
	sInt-=max([int(c) for c in start])
	start=str(sInt)
	counter+=1
print(counter)


n=int(input())
k=0

while n:
    n-=int(max(list(str(n))))
    k+=1

print(k)


num=int(input())
ans=0
while(num!=0):
    L=list(str(num))
    d=int(max(L))
    num-=d
    ans+=1
print(ans)


n,k=int(input()),0
while n:n-=int(max(list(str(n))));k+=1
print(k)

n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)

n=int(input())
count=0
while n>0:
     n-=int(max(str(n)))
     count+=1
print(count)

a = int(input())
k = 0
while a>0:
    a -= max([int(c) for c in str(a)])
    k += 1
print(k)

import sys
fin = sys.stdin

n = int(fin.readline())

count = 0
while n > 0:
    count += 1
    n -= max(map(int, str(n)))
    
print(count)

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):
    nonlocal 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]) 

import sys
sys.setrecursionlimit(15000000)
def solve():
    n = int(input())
    mem = [1000000] * (n + 1)
    mem[0] = 0
    for i in range(1, n + 1):
        ncopy = i
        while ncopy > 0:
            last = ncopy % 10
            ncopy //= 10
            if last != 0 and i - last >= 0: mem[i] = min(mem[i], 1 + mem[i - last])
    print(mem[n])
    
if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()

n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)

n=int(input())
dp=[0]+[1e9+7]*(n)
for i in range(1,n+1):
	tmp=i
	while tmp:
		dp[i]=min(dp[i],dp[i-tmp%10]+1)
		tmp//=10
print(int(dp[n]))

n,a=int(input()),0
while n:
	n-=int(max(str(n)))
	a+=1
print(a)

n = int(input())

count = 0
while n:
	n -= max(list(map(int,str(n))))
	count += 1

print(count)

n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n,k=int(input()),0
while n:n-=int(max(str(n)));k+=1
print(k)


n = int(input())

def naive(n):
	c=0
	#print(n,end='\t')
	while n!=0:
		c+=1
		n-=max([int(x) for x in list(str(n))])
		#print(n)
	print(c)

# d=dict()
# d[0]=0
# def dp(n):
# 	if(n==0):
# 		return 0
# 	s=[int(x) for x in list(str(n))]
# 	minimo=n
# 	s=max(s)
# 	temp = n - s
# 	return dp(temp)+1

# for x in range(1,10,1):
# 	naive(x)
# for x in range(10,100,10):
# 	naive(x)
# for x in range(100,1000,100):
# 	naive(x)
# for x in range(1000,10000,1000):
# 	naive(x)
# for x in range(5000,6000,100):
# 	naive(x)

naive(n)

s = int(input())
cnt = 0
while s:
    s -= max(map(int, str(s)))
    cnt += 1
print(cnt)