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.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		StreamInputReader in = new StreamInputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    private int[][] A;
    private int[][] sumB;
    private int[][][] mem;
    private int[][][] calc;
    private int[][] req;
    private int[] coords;

	public void solve(int testNumber, StreamInputReader in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();

        A = new int[N + 1][M + 1];
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= M; j++) {
                char c = in.nextCharacter();
                A[i][j] = (c == '.' ? 0 : 1);
            }

        sumB = new int[N + 1][M + 1];
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= M; j++)
                sumB[i][j] = sumB[i - 1][j] + sumB[i][j - 1] - sumB[i - 1][j - 1] + A[i][j];

        calc = new int[N + 1][M + 1][9];
        mem = new int[N + 1][M + 1][9];

        req = new int[9][16];
        for(int pat = 0; pat < 16; pat++)
            req[1][pat] = Integer.bitCount(pat);
        for(int size = 2; size < 9; size++)
            for(int pat = 0; pat < 16; pat++) {
                req[size][pat] = Integer.bitCount(pat) * (1 << (size - 1)) * (1 << (size - 1));
                req[size][pat] += (4 - Integer.bitCount(pat)) * req[size - 1][pat];
            }

        int ans = 0;
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= M; j++) {
                int size = Math.min(i, M - j + 1);
                for(int p = 2; (1 << p) <= size; p++) {
                    for(int pattern = 0; pattern < 16; pattern++) {
                        if(fits(i, j, p, pattern) && black(i, j, i - (1 << p) + 1, j + (1 << p) - 1) == req[p][pattern])
                            ans++;
                    }
                }
            }

        out.print(ans);
	}

    private boolean fits(int pi, int pj, int size, int pat) {
        if((calc[pi][pj][size] & (1 << pat)) > 0) {
            if((mem[pi][pj][size] & (1 << pat)) > 0)
                return true;
            return false;
        }

        int i;
        for(i = 0; i < 4; i++) {
            coords = getCoords(pi, pj, size, i);
            if(((1 << i) & pat) > 0) {
                int b = black(coords[0], coords[1], coords[2], coords[3]);
                if(b != ((1 << (size - 1)) * (1 << (size - 1))))
                    break;
            }
            else {
                boolean b = false;
                if(size > 1)
                    b = fits(coords[0], coords[1], size - 1, pat);
                else {
                    if(A[coords[0]][coords[1]] == 0)
                        b = true;
                }
                if(!b) {
                    break;
                }
            }
        }

        calc[pi][pj][size] |= (1 << pat);
        if(i == 4) {
            mem[pi][pj][size] |= (1 << pat);
            return true;
        }
        return false;
    }

    private int black(int i1, int j1, int i2, int j2) {
        return sumB[i1][j2] - sumB[i2 - 1][j2] - sumB[i1][j1 - 1] + sumB[i2 - 1][j1 - 1];
    }

    private int[] getCoords(int pi, int pj, int size, int square) {
        int[] ret = new int[4];
        size--;
        if(square == 0) {
            ret[0] = pi - (1 << size);
            ret[1] = pj;
            ret[2] = pi - (1 << (size + 1)) + 1;
            ret[3] = pj + (1 << size) - 1;
        }
        if(square == 1) {
            ret[0] = pi - (1 << size);
            ret[1] = pj + (1 << size);
            ret[2] = pi - (1 << (size + 1)) + 1;
            ret[3] = pj + (1 << (size + 1)) - 1;
        }
        if(square == 2) {
            ret[0] = pi;
            ret[1] = pj;
            ret[2] = pi - (1 << size) + 1;
            ret[3] = pj + (1 << size) - 1;
        }
        if(square == 3) {
            ret[0] = pi;
            ret[1] = pj + (1 << size);
            ret[2] = pi - (1 << size) + 1;
            ret[3] = pj + (1 << (size + 1)) - 1;
        }
        return ret;
    }
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar, numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    }

abstract class InputReader {

    public abstract int read();

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public char nextCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }