#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;
    }
    }
    int main(){
    int i;
    cin>>i;
    for(int y=0;;y++){
        if(i==fanshu(i)){
            cout<<y;
            
        }
        i+=fanshu(i);
    }
}
/**************************************************************
	Problem: 1083
	User: yangjunwen
	Language: C++
	Result: Time Limit Exceed
****************************************************************/