#include <bits/stdc++.h>
using namespace std;
int md(int n)
{
if (n < 10) return n;
int s = 0;
while (n != 0)
{
s = max(s, n%10);
n /= 10;
}
return s;
}
int main()
{
int n;
cin >> n;
int res = 0;
while (n != 0)
{
n = n - md(n);
res++;
}
cout << res;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWQoaW50IG4pCnsKICAgIGlmIChuIDwgMTApIHJldHVybiBuOwogICAgaW50IHMgPSAwOwogICAgd2hpbGUgKG4gIT0gMCkKICAgIHsKICAgICAgICBzID0gbWF4KHMsIG4lMTApOwogICAgICAgIG4gLz0gMTA7CiAgICB9CiAgICByZXR1cm4gczsKfQoKaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgaW50IHJlcyA9IDA7CiAgICB3aGlsZSAobiAhPSAwKQogICAgewogICAgICAgIG4gPSBuIC0gbWQobik7CiAgICAgICAgcmVzKys7CiAgICB9CiAgICBjb3V0IDw8IHJlczsKfQo=