Code Golf: 6174 - Kaprekar's mythical constant Why is the number 6174 so interesting? As defined by Wikipedia


  
  Take any four-digit number, using at
  least two different digits. (Leading
  zeros are allowed.)
  Arrange the digits in ascending and
  then in descending order to get two
  four-digit numbers, adding leading
  zeros if necessary.
  Subtract the smaller number from the
  bigger number.
  Go back to step 2.
  
  
  The above process, known as Kaprekar's
  routine, will always reach 6174 in at
  most 7 iterations. Once 6174 is
  reached, the process will continue
  yielding it.


Write a program which runs the Kaprekar's routine against a given four-digit number (see definition above) printing out each step of the routine.

Rules:


Submissions must be complete
programs.
Input must be read from standard
input. Piping from echo is OK.
Input should be in numeric form.
Printing out leading zeros is
required. (See examples below.)
Last line should say how many
iterations were needed. Punctuation is required.


Examples:

&gt; 2607
7620 - 0267 = 7353
7533 - 3357 = 4176
7641 - 1467 = 6174
Iterations: 3.

&gt; 1211
2111 - 1112 = 0999
9990 - 0999 = 8991
9981 - 1899 = 8082
8820 - 0288 = 8532
8532 - 2358 = 6174
Iterations: 5.

&gt; 6174
7641 - 1467 = 6174
Iterations: 1.


Any programming language is welcome. Extra points for esoteric ones + a small bounty. 

Update 1: There is already a similar question.

Update 2: Added example for 6174 as input. Thanks to Peter Taylor for the notice.
Ruby 1.9, 122 characters
puts&quot;Iterations: #{(1..7).find{s=$_.chars.sort*&quot;&quot;;puts [r=s.reverse,?-,s,?=,$_=&quot;%04d&quot;%(r.to_i-s.to_i)]*&quot; &quot;;~/6174/}}.&quot;

Example invocation:
$ echo 1211 | ruby -ln kaprekar.rb

I've counted the -ln flag as 4 characters (difference between the normal invocation ruby kaprekar.rb and ruby -ln kaprekar.rb).