You are given an n × m grid, some of its nodes are black, the others are white. Moreover, it's not an ordinary grid — each unit square of the grid has painted diagonals.

The figure below is an example of such grid of size 3 × 5. Four nodes of this grid are black, the other 11 nodes are white.

<image>

Your task is to count the number of such triangles on the given grid that:

  * the corners match the white nodes, and the area is positive; 
  * all sides go along the grid lines (horizontal, vertical or diagonal); 
  * no side contains black nodes. 

Input

The first line contains two integers n and m (2 ≤ n, m ≤ 400). Each of the following n lines contain m characters (zeros and ones) — the description of the grid. If the j-th character in the i-th line equals zero, then the node on the i-th horizontal line and on the j-th vertical line is painted white. Otherwise, the node is painted black.

The horizontal lines are numbered starting from one from top to bottom, the vertical lines are numbered starting from one from left to right. 

Output

Print a single integer — the number of required triangles.

Examples

Input

3 5
10000
10010
00001


Output

20


Input

2 2
00
00


Output

4


Input

2 2
11
11


Output

0

Note

The figure below shows red and blue triangles. They are the examples of the required triangles in the first sample. One of the invalid triangles is painted green. It is invalid because not all sides go along the grid lines.

<image>
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.io.*;

public class D {

	public D () {
		int N = sc.nextInt();
		int M = sc.nextInt();
		char [][] G = sc.nextChars(N);
		deepClone(G);
		for (char [] g : G)
			for (int i : rep(M))
				g[i] -= '0';

		int [][][] H = new int [2][N][M];
		for (int [][] hh : H) for (int [] h : hh) fill (h, -1);
		for (int r : rep(N)) {
			int p = 0;
			while (p < M) {
				while (p < M && G[r][p] == 1) ++p;
				int q = p; while (q < M && G[r][q] == 0) ++q;
				for (int i : rep(p, q)) {
					H[0][r][i] = i - p;
					H[1][r][i] = q - 1 - i;
				}
				p = q;
			}
		}

		int [][][] V = new int [2][N][M];
		for (int [][] vv : V) for (int [] v : vv) fill (v, -1);
		for (int c : rep(M)) {
			int p = 0;
			while (p < N) {
				while (p < N && G[p][c] == 1) ++p;
				int q = p; while (q < N && G[q][c] == 0) ++q;
				for (int i : rep(p, q)) {
					V[0][i][c] = i - p;
					V[1][i][c] = q - 1 - i;
				}
				p = q;
			}
		}

		int [][][] D = new int [2][N][M];
		for (int [][] dd : D) for (int [] d : dd) fill(d, -1);
		for (int r : rep(N)) {
			int p = 0, Z = min(N-r, M);
			while (p < Z) {
				while (p < Z && G[r+p][p] == 1) ++p;
				int q = p; while (q < Z && G[r+q][q] == 0) ++q;
				for (int i : rep(p, q)) {
					D[0][r+i][i] = i - p;
					D[1][r+i][i] = q - 1 - i;
				}
				p = q;
			}
		}
		for (int c : rep(M)) {
			int p = 0, Z = min(N, M-c);
			while (p < Z) {
				while (p < Z && G[p][c+p] == 1) ++p;
				int q = p; while (q < Z && G[q][c+q] == 0) ++q;
				for (int i : rep(p, q)) {
					D[0][i][c+i] = i - p;
					D[1][i][c+i] = q - 1 - i;
				}
				p = q;
			}
		}

		int [][][] E = new int [2][N][M];
		for (int [][] ee : E) for (int [] e : ee) fill(e, -1);
		for (int r : rep(N)) {
			int p = 0, Z = min(r+1, M);
			while (p < Z) {
				while (p < Z && G[r-p][p] == 1) ++p;
				int q = p; while (q < Z && G[r-q][q] == 0) ++q;
				for (int i : rep(p, q)) {
					E[0][r-i][i] = i - p;
					E[1][r-i][i] = q - 1 - i;
				}
				p = q;
			}
		}
		for (int c : rep(M)) {
			int p = 0, Z = min(N, M-c);
			while (p < Z) {
				while (p < Z && G[N-1-p][c+p] == 1) ++p;
				int q = p; while (q < Z && G[N-1-q][c+q] == 0) ++q;
				for (int i : rep(p, q)) {
					E[0][N-1-i][c+i] = i - p;
					E[1][N-1-i][c+i] = q - 1 - i;
				}
				p = q;
			}
		}

		int res = 0;
		for (int i : rep(N-1))
			for (int j : rep(M-1)) {
				int S = G[i][j] + G[i][j+1] + G[i+1][j] + G[i+1][j+1];
				if (S == 1) ++res;
				if (S == 0) res += 4;
			}

		// hbase - down
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(H[1][i][j]/2, E[1][i][j]);
				for (int k : req(1, Z))
					if (D[1][i-k][j+k] >= k)
						++res;
			}

		//hbase - up
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(H[1][i][j]/2, D[1][i][j]);
				for (int k : req(1, Z))
					if (E[1][i+k][j+k] >= k)
						++res;
			}

		//vbase - left
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(V[1][i][j]/2, E[0][i][j]);
				for (int k : req(1, Z))
					if (D[1][i+k][j-k] >= k)
						++res;
			}

		//vbase - right
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(V[1][i][j]/2, D[1][i][j]);
				for (int k : req(1, Z))
					if (E[0][i+k][j+k] >= k)
						++res;
			}

		//dbase - lu
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(D[1][i][j], V[1][i][j]);
				for (int k : req(2, Z))
					if (H[1][i+k][j] >= k)
						++res;
			}

		//dbase - rd
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(D[1][i][j], H[1][i][j]);
				for (int k : req(2, Z))
					if (V[1][i][j+k] >= k)
						++res;
			}

		//ebase - ld
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(E[1][i][j], V[0][i][j]);
				for (int k : req(2, Z))
					if (H[1][i-k][j] >= k)
						++res;
			}

		//ebase - ru
		for (int i : rep(N))
			for (int j : rep(M)) {
				int Z = min(E[1][i][j], H[1][i][j]);
				for (int k : req(2, Z))
					if (V[0][i][j+k] >= k)
						++res;
			}

		exit(res);
	}

	private static <T> T [] deepClone(T [] A) {
		try {
			ByteArrayOutputStream bout = new ByteArrayOutputStream();
			ObjectOutputStream  out = new ObjectOutputStream(bout);
			out.writeObject(A);
			ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
			ObjectInputStream in = new ObjectInputStream(bin);
			@SuppressWarnings("unchecked") T [] res = (T[]) in.readObject();
			return res;
		} catch (Exception e) {
			throw new Error(e);
		}
	}
	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { if (T <= S) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	private static int [] req(int S, int T) { return rep(S, T+1); }
	////////////////////////////////////////////////////////////////////////////////////
	private final static IOUtils.MyScanner sc = new IOUtils.MyScanner();
	private static void exit (Object o, Object ... A) { IOUtils.print(o, A); IOUtils.exit(); }
	private static class IOUtils {
		public static class MyScanner {
			public String next() { newLine(); return line[index++]; }
			public int nextInt() { return Integer.parseInt(next()); }
			public char [] nextChars() { return next ().toCharArray (); }
			public char [][] nextChars(int N) {
				char [][] res = new char [N][];
				for (int i = 0; i < N; ++i)
					res[i] = nextChars();
				return res;
			}
			//////////////////////////////////////////////
			private boolean eol() { return index == line.length; }
			private String readLine() {
				try {
					return r.readLine();
				} catch (Exception e) {
					throw new Error (e);
				}
			}
			private final java.io.BufferedReader r;
			private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
			private MyScanner (java.io.BufferedReader r) {
				try {
					this.r = r;
					while (!r.ready())
						Thread.sleep(1);
					start();
				} catch (Exception e) {
					throw new Error(e);
				}
			}
			private String [] line;
			private int index;
			private void newLine() {
				if (line == null || eol()) {
					line = split(readLine());
					index = 0;
				}
			}
			private String [] split(String s) { return s.length() > 0 ? s.split(" ") : new String [0]; }
		}
		private static String build(Object o, Object ... A) { return buildDelim(" ", o, A); }
		private static String buildDelim(String delim, Object o, Object ... A) {
			StringBuilder b = new StringBuilder();
			append(b, o, delim);
			for (Object p : A)
				append(b, p, delim);
			return b.substring(delim.length());
		}
		//////////////////////////////////////////////////////////////////////////////////
		private static void start() { if (t == 0) t = millis(); }
		private static void append(StringBuilder b, Object o, String delim) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++i)
					append(b, java.lang.reflect.Array.get(o, i), delim);
			} else if (o instanceof Iterable<?>)
				for (Object p : (Iterable<?>) o)
					append(b, p, delim);
			else {
				if (o instanceof Double)
					o = new java.text.DecimalFormat("#.############").format(o);
				b.append(delim).append(o);
			}
		}
		private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out);
		private static void print(Object o, Object ... A) { pw.println(build(o, A)); }
		private static void err(Object o, Object ... A) { System.err.println(build(o, A)); }
		private static void exit() {
			IOUtils.pw.close();
			System.out.flush();
			err("------------------");
			err(IOUtils.time());
			System.exit(0);
		}
		private static long t;
		private static long millis() { return System.currentTimeMillis(); }
		private static String time() { return "Time: " + (millis() - t) / 1000.0; }
	}
	public static void main (String[] args) { new D(); IOUtils.exit(); }
}
