Write a Rectangular Program that Outputs the Number of Times it was Rotated The title says it all. Your goal is to write a program that forms a w×h rectangle of characters that can be rotated and re-run to output the number of 90° Counter-Clockwise (CCW) rotations that have been done.

For example, if the 3×2 program

abc
def


solved the problem, it would initially output 0, and successive rotations of 90° CCW

cf    fed    da
be    cba    eb
ad           fc


would output 1, 2, and 3 respectively.

Using comments makes this a trivial task is most languages. In Ruby for example, it can be done in a 7×7 rectangle:

###p###
### ###
###1###
p 0#2 p
###3###
### ###
###p###


The challenge is to do this without any sort of comments.

Scoring

Your score is w*h, the area of your rectangle. Newlines are excluded. In other words, code-golf, newlines not counted.

The score for the Ruby example is 49 (though of course it is invalid since it has comments).

Notes


Your code must really be rectangular with no missing characters at the end of lines.
If you wish you may output other legal "mod 90°" values instead of 0 1 2 3. So 8 is fine instead of 0, and -1 is fine instead of 3, etc.
The output may go to the console or into a file.
Standard loopholes apply.


I hope this, my first question, really intrigues some people. Enjoy!
APL (1x3 = 3)

5!3


This solution uses the extra rule that any output that is correct mod 4 works.

In APL, x!y is the number of way to choose x elements from y, commonly known as binom(y,x) or choose(y,x). Let's check that each rotation gives the right answer.

0 rotations

5!3


There's no way to choose 5 elements from 3, so we get 0, which is automatically printed.

1 CCW rotation

3
!
5


APL happily evaluates each line, getting the number 3, the operator !, and then the number 5, printing only the last of these (5), which is 1 mod 4.

2 CCW rotations

3!5


This is binom(5,3), which is (5*4*3*2*1)/(3*2*1)/(2*1) = 10, which is 2 mod 4.

3 CCW rotations

5
!
3


As before, only the last-evaluated value of 3 is printer.

I don't actually know APL, so please tell me if I got any of the explanation wrong. I found it by trial and error as the first language on this site that:


Automatically prints the result of an expression
Given multiple lines of expressions, only outputs the last one
Has no issue with an operator standing alone on a line
Takes operators infix
Has a single-character arithmetic binary operator that is asymmetric (aRb != bRa), and flexible enough to return a variety of numbers.


For (5), I went down the list of APL dyadic functions. My first candidate operation was the integer division / of C and Python 2, but APL division ÷ gives floats. Exponentiation is tempting, but fails because a and a^b have the same parity but are gotten by consecutive rotations (unless b=0, but then b^a=0). Boolean operators like &lt; give 0 and 1 180 degrees apart, which doesn't work. Finally, I found the binomial operator ! and tried numbers until I got some that work.

Thanks to Quincunx for his confidence that there exists a smaller solution than 2x2.