Write a program that outputs the number 0.
That's a bit trivial, isn't it?
Let the length of your program be \$S\$. Write a program that outputs the number 0. When your program is cyclically shifted \$i < S\$ bytes left, it should output \$i\$. To cyclically shift a string \$i\$ bytes left means to move the last \$i\$ bytes (including newlines) to the front, without changing the order.
For example, if your code is
ABCD should output 0;
DABC should output 1;
CDAB should output 2;
BCDA should output 3.
- Your program must be at least 3 bytes long.
- "Output" represents any acceptable output: on the stack, to STDOUT, as a return value, as an exit code, etc.
- Your program is to not take any form of input.
- This is code-golf, so shortest code wins.