Shrink a number string Given a string of 1 and 2 of any length, write some code (doesn't have to be a function anymore, everything will be just fine) that calculates how many steps does it need to shrink the string to a final form, following this criterion:

If your string is 112112, this means that you have to print a 1, two 1s and a 2, like this:
1112. When you'll perform the operation again you'll have to print a 1 and a 2. You get 12. Then you print one 2, obtaining 2. This is a final form, since this string is not going to change anymore. Your code will output 3, since you needed 3 steps to get to the final form.

Other Rules


If the string has uneven length, the last number remains untouched.
Every string that cannot change anymore (like 222222) is considered a final form.
You cannot use any external source.
Your code must work with every string of 1 and 2.
Shortest code wins, as it is code-golf.
Your code should print every step.
Every input method will be fine.


Examples

Input &gt;&gt; 122122122121212212

Your code has to print:
211222111111222
11222111222
122111222
2111222
111222
1222
222
Steps:7 (you can omit the "Steps")
---- ---- ---- ----
Input &gt;&gt; 22222221

Your code has to print:
22222211
2222221
2
---- ---- ---- ----
Input &gt;&gt; 2222

Your code has to print:
0


EDIT: Heavily edited. So sorry about that.
Ruby 1.9+, 73 characters

I see the no-regex rule as silly and arbitrary, so here's a spiteful regex based solution:

gets
($.+=1;puts$_.gsub!(/(.)(.)/){$2*$1.to_i})until~/^(22)*[12]?$/
p~-$.


Test run:

$ ruby 21.rb &lt;&lt;&lt; 122122122121212212
211222111111222
11222111222
122111222
2111222
111222
1222
222
7


The last line is the number of steps.

Edit: Regex restriction has been removed by Vereos.