Problem: Little Vasya likes painting fractals very much.

He does it like this. First the boy cuts out a 2 × 2-cell square out of squared paper. Then he paints some cells black. The boy calls the cut out square a fractal pattern. Then he takes a clean square sheet of paper and paints a fractal by the following algorithm:

  1. He divides the sheet into four identical squares. A part of them is painted black according to the fractal pattern. 
  2. Each square that remained white, is split into 4 lesser white squares, some of them are painted according to the fractal pattern. Each square that remained black, is split into 4 lesser black squares. 



In each of the following steps step 2 repeats. To draw a fractal, the boy can make an arbitrary positive number of steps of the algorithm. But he need to make at least two steps. In other words step 2 of the algorithm must be done at least once. The resulting picture (the square with painted cells) will be a fractal. The figure below shows drawing a fractal (here boy made three steps of the algorithm).

<image>

One evening Vasya got very tired, so he didn't paint the fractal, he just took a sheet of paper, painted a n × m-cell field. Then Vasya paint some cells black. 

Now he wonders, how many squares are on the field, such that there is a fractal, which can be obtained as described above, and which is equal to that square. Square is considered equal to some fractal if they consist of the same amount of elementary not divided cells and for each elementary cell of the square corresponding elementary cell of the fractal have the same color.

Input

The first line contains two space-separated integers n, m (2 ≤ n, m ≤ 500) — the number of rows and columns of the field, correspondingly. 

Next n lines contain m characters each — the description of the field, painted by Vasya. Character "." represents a white cell, character "*" represents a black cell.

It is guaranteed that the field description doesn't contain other characters than "." and "*".

Output

On a single line print a single integer — the number of squares on the field, such that these squares contain a drawn fractal, which can be obtained as described above.

Examples

Input

6 11
......*.***
*.*.*....**
.***....*.*
..***.*....
.*.*.....**
......*.*..


Output

3


Input

4 4
..**
..**
....
....


Output

0

Note

The answer for the first sample is shown on the picture below. Fractals are outlined by red, blue and green squares.

<image>

The answer for the second sample is 0. There is no fractal, equal to the given picture.

<image>

Solution (in JAVA):

Solution:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;


public class TaskC
{

  /**
   * @param args
   * @throws FileNotFoundException 
   */
  int strCnt, colCnt;
  int Mtx[][];
  int MtxPrefix[][];
  byte lTop = 0b00000001;
  byte rTop = 0b00000010;
  byte lBot = 0b00000100;
  byte rBot = 0b00001000;
  
  public static void main(String[] args) throws FileNotFoundException
  {
    long timeStart = System.currentTimeMillis();
    TaskC solver = new TaskC();    
    System.out.print(solver.getFCount());
    long workingTime = System.currentTimeMillis() - timeStart;
//    System.out.print("\nWorking time: " + workingTime);
  }
  
  private boolean testPixel(int str, int col, boolean black)
  {    
    return (Mtx[str][col] == 1) == black;
  }
  
  private boolean maskIsBlackAt(byte mask, int str, int col)
  {
    if (str == 0 & col == 0)
      return (mask & lTop) == lTop;
    else if (str == 0 & col == 1)
      return (mask & rTop) == rTop;
    else if (str == 1 & col == 0)
      return (mask & lBot) == lBot;
    else if (str == 1 & col == 1)
      return (mask & rBot) == rBot;
    return false;
  }
  
  private boolean testBlackArea(int firstStr, int firstCol, int size)
  {
    return testMonoArea(firstStr, firstCol, size, 1);
  }
  
  private boolean testMonoArea(int firstStr, int firstCol, int size, int color)
  {
    int blackCount = 0;
    for (int str = firstStr; str < firstStr + size; str++)
    {
      blackCount += MtxPrefix[str][firstCol + size - 1];
      if (firstCol > 0)
        blackCount -= MtxPrefix[str][firstCol - 1];
    }
            
//    int blackCount = MtxPrefix[firstStr + size - 1][firstCol + size - 1] -
//                     MtxPrefix[firstStr][firstCol];
    if (color == 1)
      return blackCount == size * size;
    else
      return blackCount == 0;
    
//    for (int str = firstStr; str < firstStr + size; str++)
//      for (int col = firstCol; col < firstCol + size; col++)
//        if (Mtx[str][col] != color)
//          return false;
//    return true;
  }
  
  private boolean testFractal(int str, int col, int size, byte mask)
  {
    if (size == 2)
    {
      boolean res = false;
      for (int dstr = 0; dstr < 2; dstr++)
        for (int dcol = 0; dcol < 2; dcol++)
        {
          res = testPixel(str + dstr, col + dcol, maskIsBlackAt(mask, dstr, dcol));
          if (!res)
            return false;
        }
      return res;
    }
    
    boolean res = true;
    for (int dstr = 0; dstr < 2; dstr++)
      for (int dcol = 0; dcol < 2; dcol++)
      {
        int strArea = str + dstr * size / 2;
        int colArea = col + dcol * size / 2;
        if (maskIsBlackAt(mask, dstr, dcol))          
          res = res & testBlackArea(strArea, colArea, size / 2);
        else
          res = res & testFractal(strArea, colArea, size / 2, mask);
        if (!res)
          return false;
      }
    
    return res;
  }
  
  public int getFCount()
  {
    int fSize = 4;
    int res = 0;
    while (fSize <= strCnt & fSize <= colCnt)
    {      
      for (int str = 0; str < strCnt - fSize + 1; str++)
        for (int col = 0; col < colCnt - fSize + 1; col++)
        {
          if (testMonoArea(str, col, fSize, Mtx[str][col]))
          {
            res++;
            continue;
          } else
            for (byte mask = 1; mask < 15; mask++)
              if (testFractal(str, col, fSize, mask))
              {
                res++;
                break;
              }
          
        }
      fSize *= 2;
    }
    return res;
  }

  TaskC() throws FileNotFoundException
  {
//    Scanner sc = new Scanner(new File("D:/programming/java/codeforces_141_c_fractals/bin/input4.txt"));
    Scanner sc = new Scanner(System.in);
    strCnt = sc.nextInt();
    colCnt = sc.nextInt();
    sc.nextLine();
    Mtx = new int[strCnt][colCnt];
    for (int str = 0; str < strCnt; str++)
    {
      String line = sc.nextLine();
      for (int col = 0; col < colCnt; col++)
        Mtx[str][col] = (line.charAt(col) == '*') ? 1 : 0;
    }       
    sc.close();
    MtxPrefix = createMtxPrefix();
  }
  
  private int[][] createMtxPrefix()
  {
    int res[][] = new int[strCnt][colCnt];
    for (int str = 0; str < strCnt; str++)
    {
      res[str][0] = Mtx[str][0];
      for (int col = 1; col < colCnt; col++)
        res[str][col] = res[str][col - 1] + Mtx[str][col];
    }
    return res;
  }
}