#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//抄博友程序
int xiao(int n)
{
vector<int> ve;
while(1)
{
if(n==0)
{
break;
}
ve.push_back(n%10);
n=n/10;
}
sort(ve.begin(),ve.end());
int a=0;
for(int i=0;i<ve.size();i++)
{
a=a*10+ve[i];
}
return a;//小
}
int da(int n)
{
vector<int> ve;
while(1)
{
if(n==0)
{
break;
}
ve.push_back(n%10);
n=n/10;
}
sort(ve.begin(),ve.end());
int a=0;
for(int i=ve.size()-1;i>=0;i--)
{
a=a*10+ve[i];
}
return a;//大
}
int main()
{
while(1)
{
int n;
cin>>n;
if(n==-1)
{
break;
}
cout<<"N="<<n<<":"<<endl;
if(xiao(n)==da(n)||n>10000||n<1000)//抄博友
{
cout<<"No!!"<<endl;
continue;
}
int i=0;
while(1)
{
i++;
int a=da(n);
int b=xiao(n);
cout<<a<<"-"<<b<<"="<<a-b<<endl;
n=a-b;
if(a==b || a-b==6174)
{
//if(i==1)
//{
// cout<<"Ok!! "<<i<<" time"<<endl;
//}else
{
cout<<"Ok!! "<<i<<" times"<<endl;
}
break;
}
}
}
return 0;
}