Time Limit : sec, Memory Limit : KB

# All Numbers Lead to 6174

Perform the following operations on a four-digit number N consisting of the digits 0 through 9.

1. Let L be the number obtained by arranging the numbers of each of the N digits in descending order.
2. Let S be the number obtained by sorting the digits of N in ascending order.
3. Let the difference L-S be the new N (end of one operation)
4. Repeat from 1. for the new N

In this case, it is known that every four-digit number will be 6174 at some point, except when all digits are the same (0000, 1111, etc.). For example, if N = 2012
1st. (N = 2012): L = 2210, S = 0122, L-S = 2088
2nd. (N = 2088): L = 8820, S = 0288, L-S = 8532
3rd. (N = 8532): L = 8532, S = 2358, L-S = 6174
and the value reaches 6174 in three operations.

Given a four-digit number from 0 to 9, write a program to calculate how many operations it takes to reach 6174.

## Input

The input consists of multiple data sets. The end of the input is indicated by a single line 0000. Each data set is given in the following format.

N


The data set is a single line, where N (1 ≤ N ≤ 9999) denotes a four-digit number. if N < 1000, the upper digits are filled with zeros.

The number of datasets does not exceed 10000.

## Output

For each data set, output the number of operations required to reach 6174 on a single line. However, if a number in which all digits are the same is given as input, the output should be "NA".

## Sample Input

6174
2012
3333
0000


## Sample Output

0
3
NA