$n=<>+0;$a=x x 14 .<>.<>.x x 14;$r=0; for$j(0..28){ $_=$a;s/\n//g;pos=$j;s/\Gx{0,$n}/o x length$&/e; $x=0; /o/?$r+=$-=++$x-$r:($x=0)for/./g; } print$r