#include<bits/stdc++.h> 
using namespace std; 
int main(){ 
    int a=0,s=0,d,z=0,x,c,f;
    cin>>c;
    for(d=0;c!=495;d++){
    	
    a=c/100;
	s=c/10%10;
	z=c%10;
    	if(a>s and a>z){
    		x=a*100+s*10+z;
    		f=z*100+s*10+a,
    		c=x-f;
		}
			if(s>a and a>z){
    		x=s*100+a*10+z;
    		f=z*100+a*10+s,
    		c=x-f;
		}
			if(z>s and s>a){
    		x=z*100+s*10+a;
    		f=a*100+s*10+z,
    		c=x-f;
		}
			if(a>z and z>s){
    		x=a*100+z*10+s;
    		f=s*100+z*10+a,
    		c=x-f;
		}
			if(z>a and a>s){
    		f=s*100+a*10+z;
    		x=z*100+a*10+s,
    		c=x-f;
		}
		    if(s>z and z>a){
    		x=s*100+z*10+a;
    		f=a*100+z*10+s,
    		c=x-f;
		}
	
	}
	cout<<d;
		return 0;
		}

2 comments

  • 1