#include <bits/stdc++.h>
using namespace std;
int fanshu(int i){
    int n=0,t=0,o=1;
    string s;
    for(;o<i;o*=10){
        s[n]=i/o%10+'0';
        n++;
    }
    for(int y=0;y<n;y++){
        o/=10;
        t+=(s[y]-'0')*o;
    }
    return t;
}
int main(){
    int i;
    cin>>i;
    for(int y=0;;y++){
        if(i==fanshu(i)){
            cout<<y;
            return 0;
        }
        i+=fanshu(i);
    }
    return 0;
}
/**************************************************************
	Problem: 1083
	User: yangjunwen
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/