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 IOException {
		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);
	}

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

		int [] nextInts() throws IOException {
			String [] L = nextStrings();
			int [] res = new int [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Integer.parseInt(L[i]);
			return res;
		}	
		
		long [] nextLongs() throws IOException {
			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;
		}

		double [] nextDoubles() throws IOException {
			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 IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}
		
		MyScanner(BufferedReader r) throws IOException { 
			this.r = r;
		}
		
		private String [] line;
		private int index;

		private void newLine() throws IOException {
			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.flush();
		System.err.println("------------------");
		System.err.println("Time: " + secs());
		System.exit(0);
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	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 IOException {
		run();
		exit();
	}

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

	static void run () throws IOException {
		sc = new MyScanner ();
		new C();
	}

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

	static double secs() {
		return (millis() - t) / 1000.0;
	}
}