#include<algorithm>#include<iostream>usingnamespace std;voiddivide(int a,int b[]){for(int i =0; i <4; i++){
b[i]= a %10;
a /=10;}}boolcmp1(int a,int b){return a > b;}boolcmp2(int a,int b){return a<b;}intsort1(int c[]){int a =0;int pow =1;//从大到小sort(c, c +4, cmp1);for(int i =3; i >=0;--i){
a += c[i]* pow;
pow *=10;}return a;}intsort2(int c[]){int b =0;sort(c, c +4, cmp1);int pow =1;for(int i =0; i <4; i++){
b += c[i]* pow;
pow *=10;}return b;}int a =0;int c =0;int b[4]={};intmain(){int n;
cin >> n;divide(n, b);int flag =0;for(int i =1; i <4; i++){if(b[i -1]!= b[i]){
flag =1;}}if(flag ==0){printf("%04d", flag);return0;}while(true){
a =sort1(b);
c =sort2(b);
cout << a <<"-"<< c <<"="<< a - c << endl;if(a - c !=6174){divide(a - c, b);}elsebreak;}return0;}