#include <iostream>
#include <algorithm>
using namespace std;
bool compare(char a, char b){ return a > b;}
int main(int argc, const char * argv[]) {
string s, a, b;
cin >> s;
s.insert(0, 4 - s.length(), '0');
do{
a = s;
b = s;
sort(a.begin(), a.end());
sort(b.begin(), b.end(), compare);
int result = stoi(b) - stoi(a);
s = to_string(result);
s.insert(0, 4 - s.length(), '0');
cout << b << " - " << a << " = " << s << endl;
}while (s != "6174" && s != "0000");
return 0;
}