Under construction

Still being built. Things may change

Complexity

Interview

Time limit2sMemory limit1024 MB

Summary
Count the unordered pairs of k by k subgrids that are not similar, where similar means one becomes the other after flipping whole rows or columns.
Level

Medium6 of 10

Topics
Matrix, Hash map
Solved
No attempts yet

Problem

Fedot is a designer who has been given an important job: laying out black and white tiles in an artistic pattern. His latest task is to lay black and white tiles on an n×nn \times n square.

Fedot loves his work and prepares carefully for every project. He considers two squares similar if one of them can be obtained from the other by flipping colors in some row or column several times.

All of these squares are similar to each other, and no other square is similar to them.

Fedot noticed that clients never look at the whole work at once. Their view is usually limited to a k×kk \times k square. To evaluate sketches, he introduced a value called complexity. It is the number of pairs of k×kk \times k squares that appear in the picture and are not similar to each other.

By trial and error, Fedot found that clients like pictures of a certain complexity. He thinks that too much complexity looks like chaos, and too little is boring.

Before laying tiles, Fedot prepared several sketches. Help him compute their complexity.

Input

The first line contains two integers nn and kk (1≤k≤n≤5001 \le k \le n \le 500). The next nn lines describe the sketch. Each line has length nn and consists only of the characters bb and ww. The character bb stands for a white tile, and ww stands for a black tile.

Output

Print one integer qq, the complexity of the picture.

Examples2

  1. Example 1

    Input
    2 1
    bw
    wb
    
    Expected output
    0
    
  2. Example 2

    Input
    3 2
    bwb
    wbb
    bbw
    
    Expected output
    3