while true
    arr = gets.chomp.split("").map(&:to_i)
    break if arr.inject(:+) == 0
    if arr.uniq.length == 1
        puts "NA"
    else
        count = 0
        until arr.join == "6174"
            arr2 = arr.sort
            arr = (arr2.reverse.join.to_i - arr2.join.to_i).to_s.split("").map(&:to_i)
            count += 1
        end
        puts count
    end
end
