include[HTML_REMOVED]
using namespace std;
bool compare(char a,char b)
{return a>b;}
string get_(string a,string b)
{
string c;c=”1166”;
for(int i=3;i>-1;–i)
{
if(b[i]>=a[i]){c[i]=char(b[i]-a[i]+48); }
else{c[i]=char(b[i]-a[i]+58);b[i-1]--;}
}
return c;
}
string xun(string c)
{
int count=0;
if(c==”6174”){cout<<”7641 - 1467 = 6174”;}
else while(!(c==”0000”||c==”6174”))
{
string a,b;
a=c;b=c;
sort(a.begin(),a.end());
sort(b.begin(),b.end(),compare);
c=get_(a,b);
cout<<b<<" "<<"-"<<" "<<a<<" "<<"="<<" "<<c<<endl;
}
return c;
}
int main()
{
string s;cin>>s;
while(s.length()!=4){s+='0';}
xun(s);
}