Compute the output length of the quadtree image compression scheme. The image is an L×L square of L2 pixels, and every pixel is either a 0-pixel or a 1-pixel.
The scheme works like this.

The length of the compressed image is the number of bits in its encoding. L is a power of 2 and 1≤L≤64.
The first line contains the integer L. Each of the next L lines contains L bits, with a single blank between two adjacent bits. Every bit is 0 or 1.
Print the length of the compressed image, that is, the number of bits, on one line.