Farmer Bill builds fences with FenceBuilder98, a VisualBasic5TM-driven machine. The machine starts in the middle of a field and receives a sequence of single character instructions telling it to move one step in a certain direction, leaving behind a 1 metre length of fence. The instructions are n for North, e for East, w for west and s for South. The machine stops building a fence when it gets a halt instruction, represented by a period (i.e. .).
Bill is smart. The instructions he feeds FenceBuilder98 always form a closed loop that never crosses itself and never lays down a fence over the same 1 metre stretch twice.
(Note that FenceBuilder98 is deficient: Bill's fences have no Gates. That will be fixed in FenceBuilder99 Professional.)
Bill would like to know how much area each fence encloses. Given a FenceBuilder98 program, he'd like to know how much area the corresponding fence will enclose.
Input: A FenceBuilder98 program is a sequence of move instructions followed by a halt instruction. Each move instruction is a letter, one of n, e, w, s, on a line by itself. The halt instruction is a period (.) on a line by itself. (``On a line by itself'' means preceded by nothing and followed immediately by a newline character.)
The input to your program is a sequence of valid FenceBuilder98 programs, each with at most 32767 move instructions.
Output: For each FenceBuilder98 program in the input, your program should print the number of square metres enclosed by the fence built by that FB98 program. (The world is flat.)
e n w s . n e s e n e s s w w w n .Corresponding sample output: