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.*;
import java.lang.reflect.*;
import java.util.*;

public class C {

	final int MOD = 1000000007;
	final double eps = 1e-12;
	final int INF = (int)1e9;
	
	public C () throws Exception {
		boolean [][][] Q = new boolean [128][][];
		String [] P = { "", "A", "B", "C", "D", "AB", "AC", "AD", "BC", "BD", "CD", "ABC", "ABD", "ACD", "BCD", "ABCD" };
		
		for (int i = 0; i < 16; ++i) {
			Q[i] = new boolean [2][2];
			Q[i][0][0] = P[i].contains("A");
			Q[i][0][1] = P[i].contains("B");
			Q[i][1][0] = P[i].contains("C");
			Q[i][1][1] = P[i].contains("D");
		}
		
		String [] C = { "A", "B", "C", "D" };
		
		/* 4, 8, 16, 32, 64, 128, 256 */
		
		for (int i = 0; i < 16; ++i)
			for (int j = 16; j < 128; j += 16) {
				int m = j + i, n = m - 16;
				int L = Q[n].length;
				Q[m] = new boolean[2*L][2*L];
				for (int x = 0; x < 2*L; ++x)
					for (int y = 0; y < 2*L; ++y)
						Q[m][x][y] = P[i].contains(C[2*(x%2) + (y%2)]) || Q[n][x/2][y/2];
			}
		
		int [] SZ = new int[128];
		for (int i = 16; i < 128; ++i)
			for (int j = 0; j < Q[i].length; ++j)
				for (int k = 0; k < Q[i].length; ++k)
					if (Q[i][j][k])
						++SZ[i];
		
		Set<Integer> SSZ = new HashSet<Integer>();
		for (int i = 16; i < 128; ++i)
			SSZ.add(SZ[i]);
	
		start();
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		boolean [][] B = new boolean [N][M];
		for (int i = 0; i < N; ++i) {
			char [] L = sc.nextChars();
			for (int j = 0; j < M; ++j)
				B[i][j] = L[j] == '*';
		}
		
		int [][] QQ = new int [N][M];
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < M; ++j) {
				if (B[i][j])
					++QQ[i][j];
				if (i > 0)
					QQ[i][j] += QQ[i-1][j];
				if (j > 0)
					QQ[i][j] += QQ[i][j-1];
				if (i > 0 && j > 0)
					QQ[i][j] -= QQ[i-1][j-1];
			}
		
		int res = 0;
		
		for (int s = 4; s <= M && s <= N; s *= 2) {
			for (int n = 0; n < N+1-s; ++n)
				for (int m = 0; m < M+1-s; ++m) {
					int sz = QQ[n+s-1][m+s-1];
					if (n > 0)
						sz -= QQ[n-1][m+s-1];
					if (m > 0)
						sz -= QQ[n+s-1][m-1];
					if (n > 0 && m > 0)
						sz += QQ[n-1][m-1];
					if (SSZ.contains(sz))
						for (int i = 16; i < 128; ++i)
							if (Q[i].length == s && SZ[i] == sz) {
								boolean good = true;
								int T = sz, F = s*s - sz;
								out: for (int j = 0; j < s; ++j)
									for (int k = 0; k < s; ++k) {
										if (T == 0 || F == 0)
											break out;
										if (Q[i][j][k] != B[n+j][m+k]) {
											good = false;
											break out;
										}
										if (Q[i][j][k])
											--T;
										else
											--F;
									}
								if (good)
									++res;
							}
				}	
		}
		
		exit(res);
	}

	////////////////////////////////////////////////////////////////////////////////////
	
	static MyScanner sc;
	
	static class MyScanner {
		public String next() throws Exception {
			newLine();
			return line[index++];
		}
		
		public char nextChar() throws Exception {
			return next().charAt(0);
		}
				
		public int nextInt() throws Exception {
			return Integer.parseInt(next());
		}
		
		public long nextLong() throws Exception {
			return Long.parseLong(next());
		}
		
		public double nextDouble() throws Exception {
			return Double.parseDouble(next());
		}
		
		public String nextLine() throws Exception {
			line = null;
			return r.readLine();
		}
		
		public String [] nextStrings() throws Exception {
			line = null;
			return r.readLine().split(" ");
		}
		
		public char [] nextChars() throws Exception {
			return next().toCharArray();
		}

		public Integer [] nextInts() throws Exception {
			String [] L = nextStrings();
			Integer [] res = new Integer [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Integer.parseInt(L[i]);
			return res;
		}	
		
		public Long [] nextLongs() throws Exception {
			String [] L = nextStrings();
			Long [] res = new Long [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Long.parseLong(L[i]);
			return res;
		}

		public Double [] nextDoubles() throws Exception {
			String [] L = nextStrings();
			Double [] res = new Double [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Double.parseDouble(L[i]);
			return res;
		}

		boolean eol() {
			return index == line.length;
		}

		//////////////////////////////////////////////
		
		private final BufferedReader r;

		MyScanner () throws Exception {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}
		
		MyScanner(BufferedReader r) throws Exception { 
			this.r = r;
			while (!r.ready())
				Thread.sleep(1);
			start();
		}
		
		private String [] line;
		private int index;

		private void newLine() throws Exception {
			if (line == null || eol()) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}		
	}
	
	static void print (Object... a) {
		pw.println(build(a));
	}

	static void exit (Object... a) {
		print(a);
		exit();
	}

	static void exit () {
		pw.close();
		System.out.flush();
		System.err.println("------------------");
		System.err.println("Time: " + ((millis() - t) / 1000.0));
		System.exit(0);
	}
	
	void NO() {
		throw new Error("NO!");
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	static void append(StringBuilder b, Object o) {
		if (o.getClass().isArray()) {
			int L = Array.getLength(o);
			for (int i = 0; i < L; ++i)
				append(b, Array.get(o, i));
		} else if (o instanceof Iterable<?>) {
			for (Object p : (Iterable<?>)o)
				append(b, p);
		} else
			b.append(" ").append(o);		
	}
	
	static String build(Object... a) {
		StringBuilder b = new StringBuilder();
		for (Object o : a)
			append(b, o);
		return b.toString().trim();		
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	public static void main(String[] args) throws Exception {
		sc = new MyScanner ();
		new C();
		exit();
	}

	static void start() {
		t = millis();
	}

	static PrintWriter pw = new PrintWriter(System.out);
	
	static long t;
	
	static long millis() {
		return System.currentTimeMillis();
	}	
}