#include <stdio.h>                                        //ÀîÃ÷Ç«
#define N 5

int main()
{
    int Strange[N];
    int i, a, max, min, b, c;
    scanf("%d", &a);
    if (a >= 100 && a <= 999)
    {
        while (1)
        {
            c = a;
            if (a >= 10 && a <= 99)
            {
                Strange[2] = 0;
            }
            for (i = 0;a >0;i++)
            {
                Strange[i] = (a % 10);
                a /= 10;
            }
            int i, j, k, temp, max;
            for (i = 0;i < N - 1;i++)
            {
                k = i;
                for (j = i + 1;j < N;j++)
                {
                    if (Strange[j] > Strange[k])
                    {
                        k = j;
                    }
                }
                if (k != i)
                {
                    temp = Strange[k];
                    Strange[k] = Strange[i];
                    Strange[i] = temp;
                }
            }
            max = Strange[0] * 100 + Strange[1] * 10 + Strange[2] * 1;
            min = Strange[2] * 100 + Strange[1] * 10 + Strange[0] * 1;
            b = max - min;
            printf("%03d - %03d = %03d\n", max, min, b);
            if (b == c)
            {
                printf("The blackhole number is %03d\n", b);
                break;
            }
            else
            {
                a = b;
            }
        }
    }
    else if (a >= 1000 && a <= 9999)
    {
        while (1)
        {
            c = a;
            if (a >= 100 && a <= 999)
            {
                Strange[3] = 0;
            }
            for (i = 0;a >0;i++)
            {
                Strange[i] = (a % 10);
                a /= 10;
            }
            int i, j, k, temp, max;
            for (i = 0;i < N - 1;i++)
            {
                k = i;
                for (j = i + 1;j < N;j++)
                {
                    if (Strange[j] > Strange[k])
                    {
                        k = j;
                    }
                }
                if (k != i)
                {
                    temp = Strange[k];
                    Strange[k] = Strange[i];
                    Strange[i] = temp;
                }
            }
            max = Strange[0] * 1000 + Strange[1] * 100 + Strange[2] * 10 + Strange[3] *1;
            min = Strange[3] * 1000 + Strange[2] * 100 + Strange[1] * 10 + Strange[0] *1;
            b = max - min;
            printf("%04d - %04d = %04d\n", max, min, b);
            if (b == c)
            {
                printf("The blackhole number is %04d\n", b);
                break;
            }
            else
            {
                a = b;
            }
        }
    }
}
