How many squares are there? This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this:

┌─┬───┬─┐
├─┼─┬─┼─┤
├─┼─┴─┼─┤
├─┼─┬─┼─┤
└─┴─┴─┴─┘


The square is made out of n x m 1x1 square, you have to count how many sub-squares (1x1, 2x2, 3x3, 4x4, 5x5, etc.) can fit within that square. Squares can be missing some grid lines (like in the example above) or be complete like in the example bellow. Which means a mathematical breakdown is not possible (as far as I know).

Inputs:


The amount of lines (n) of input to build the square;
A square made from the following characters: ─ ┐ ┌ └ ┴ ┘ ┬ ├ ┤ ┼ | across n lines of input.


Output:


The amount of squares of any size that can fit within the input square (we only want a single number here, not a number for each size).


Winning criterion:

The smallest answer (number of bytes) wins.

Test Cases:

In:

5
┌─┬─┬─┬─┐
├─┼─┼─┼─┤
├─┼─┼─┼─┤
├─┼─┼─┼─┤
└─┴─┴─┴─┘


Out: 30



In:

3
┌─┬─┐
├─┼─┤
└─┴─┘


Out: 5



In:

5
┌─┬─┐
├─┴─┤
├───┤
├─┬─┤
└─┴─┘


Out: 7



In:

4
┌─┬─┬─┬─┬─┬─┐
├─┼─┼─┼─┼─┼─┤
├─┼─┼─┼─┼─┼─┤
└─┴─┴─┴─┴─┴─┘


Out: 32



In:

2
┌─┐
└─┘


Out: 1



In:

4
┌─┬─┬─┬─┬─┬─┐
├─┴─┼─┼─┼─┴─┤
├─┬─┼─┼─┼─┬─┤
└─┴─┴─┴─┴─┴─┘


Out: 22
JavaScript (ES6), 292 bytes 306 325

Edit I did the byte count totally wrong, corrected now thx http://bytesizematters.com/ correct for the last time I hope thx  Cᴏɴᴏʀ O'Bʀɪᴇɴ see https://goo.gl/LSHC1U (and 1 byte less using a literal newline insteads of '\n')

(h,z)=&gt;(o=&gt;{r=p=&gt;" ),┌(─┐┬'└│├┘┴┤┼".search(z[p]);for(q=s=0;++s&lt;o/2&amp;s&lt;h;)for(y=0;y&lt;(h-s)*o;y+=o)for(x=0;x&lt;o-s*2;q+=!n,x+=2)for(n=i=0,t=x,u=y;i&lt;=s;t+=2,u+=o,i++)n|=i&lt;s&amp;(!(r(t+y)&amp;r(t+y+s*o)&amp;1)|!(r(x+u)&amp;r(x+u+s*2)&amp;2))|i&gt;0&amp;(!(r(t+y)&amp;r(t+y+s*o)&amp;4)|!(r(x+u)&amp;r(x+u+s*2)&amp;8))})(-~z.search`
`)|q


Longer than I expected (probably a few more byte can be shaved off)

All possible squares are checked and counted.  

The r function map each character to a bitmap having


1 : horizontal line center to right
2 : vertical line center to bottom
4 : horizontal line center to left
8 : vertical line center to top


A square of any size must have 


4 in all cells except the first in top and bottom row
1 in all cells except the last in top and bottom row
8 in all cells except the first in leftmost and rightmost column
2 in all cells except the last in leftmost and rightmost column


Test



f=(h,z)=&gt;(o=&gt;{r=p=&gt;" ),┌(─┐┬'└│├┘┴┤┼".search(z[p]);k=(p,d,m)=&gt;r(p)&amp;r(p+s*d)&amp;m;for(q=s=0;++s&lt;o/2&amp;s&lt;h;)for(y=0;y&lt;(h-s)*o;y+=o)for(x=0;x&lt;o-s*2;q+=!n,x+=2)for(n=i=0,t=x,u=y;i&lt;=s;t+=2,u+=o,i++)n=n|i&lt;s&amp;(!k(t+y,o,1)|!k(x+u,2,2))|i&gt;0&amp;(!k(t+y,o,4)|!k(x+u,2,8));})(-~z.search`
`)|q

console.log=(...x)=&gt;O.textContent+=x+'\n'

// Less golfed

Uf=(h,z)=&gt;{
  o=-~z.search`\n`;
  w=o/2;
  r=p=&gt;" ),┌(─┐┬'└│├┘┴┤┼".search(z[p]);
  k=(p,d,m)=&gt;r(p)&amp;r(p+s*d)&amp;m;
  for(q=s=0;++s&lt;w&amp;s&lt;h;)
    for(y=0;y&lt;(h-s)*o;y+=o)
      for(x=0;x&lt;(w-s)*2;q+=!n,x+=2)
        for(n=i=0,t=x,u=y;i&lt;=s;t+=2,u+=o,i++)
          n|=i&lt;s&amp;(!k(t+y,o,1)|!k(x+u,2,2))
          |i&gt;0&amp;(!k(t+y,o,4)|!k(x+u,2,8));
  return q
}

;[[5,`┌─┬───┬─┐
├─┼─┬─┼─┤
├─┼─┴─┼─┤
├─┼─┬─┼─┤
└─┴─┴─┴─┘`,20]
,[5,`┌─┬─┬─┬─┐
├─┼─┼─┼─┤
├─┼─┼─┼─┤
├─┼─┼─┼─┤
└─┴─┴─┴─┘`,30]
,[3,`┌─┬─┐
├─┼─┤
└─┴─┘`,5]
,[5,`┌─┬─┐
├─┴─┤
├───┤
├─┬─┤
└─┴─┘`,7]
,[4,`┌─┬─┬─┬─┬─┬─┐
├─┼─┼─┼─┼─┼─┤
├─┼─┼─┼─┼─┼─┤
└─┴─┴─┴─┴─┴─┘`,32]
,[2,`┌─┐
└─┘`,1]
,[4,`┌─┬─┬─┬─┬─┬─┐
├─┴─┼─┼─┼─┴─┤
├─┬─┼─┼─┼─┬─┤
└─┴─┴─┴─┴─┴─┘`,22],
,[6,`┌─┬─────┐
├─┼─┬─┐ │
│ ├─┼─┼─┤
│ └─┼─┼─┤
│   └─┼─┤
└─────┴─┘`,12],  
,[6,`┌─┬─┬─┬─┐
├─┴─┼─┼─┤
│   └─┼─┤
├─┬─┬─┼─┤
├─┼─┼─┼─┤
└─┴─┴─┴─┘`,23]]  
.forEach(t=&gt;{
  var r=t[0],a=t[1],k=t[2],x=f(r,a)
  console.log(x==k?'OK '+x:'KO '+x+' Expected '+k,'\n'+a)
})
&lt;pre id=O&gt;&lt;/pre&gt;