#include <stdio.h>
#include<string.h>
void high(int x[],int l)
{
int b=0;
for(int i=0;i<l;i++)
{
for(int j=0;j<l;j++)
{
if(x[i]>x[j])
{
b=x[i];
x[i]=x[j];
x[j]=b;
}
}
}
}
void low(int x[],int l)
{
int b=0;
for(int i=0;i<l;i++)
{
for(int j=0;j<l;j++)
{
if(x[i]<x[j])
{
b=x[i];
x[i]=x[j];
x[j]=b;
}
}
}
}
int main() {
char a[10000];
int l,p=1,d=0,c;
int b[1000],x[10000],y[10000];
scanf("%s",a);
while(p)
{
d++;
l=strlen(a);
for(int i=0;i<l;i++)
{
b[i]=a[i]-'0';
}
high(b,l);
for(int i=0;i<l;i++)
{
x[d]=x[d]*10+b[i];
}
low(b,l);
for(int i=0;i<l;i++)
{
y[d]=y[d]*10+b[i];
}
sprintf(a,"%d",x[d]-y[d]);
c=x[d]-y[d];
for(int i=0;i<d-1;i++)
{
if(c==x[d]-y[d])
{
p=1;
}
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: