#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) pt(x / 10);
  putchar(x % 10 + '0');
}
const int inf = 0x3f3f3f3f;
const int N = 400 + 100;
char mp[N][N];
int sum[N][N][2];
int n, m;
inline bool ok(int x, int y, int a, int b) {
  if (x > a) swap(x, a), swap(y, b);
  if (x < a && y < b) return (sum[a][b][0] - sum[x - 1][y - 1][0] == 0);
  return (sum[x][y][1] - sum[a + 1][b - 1][1] == 0);
}
inline bool judge(int x, int y) {
  return (x >= 1 && x <= n && y >= 1 && y <= m && mp[x][y] == '0');
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= int(n); i++) scanf("%s", mp[i] + 1);
  for (int i = 1; i <= int(n); i++)
    for (int j = 1; j <= int(m); j++)
      sum[i][j][0] = sum[i - 1][j - 1][0] + (mp[i][j] == '1');
  for (int i = 0; i < int(n); i++)
    for (int j = 1; j <= int(m); j++)
      sum[n - i][j][1] = sum[n - i + 1][j - 1][1] + (mp[n - i][j] == '1');
  int ans = 0;
  for (int x = 1; x <= int(n); x++)
    for (int y = 1; y <= int(m); y++) {
      if (mp[x][y] == '1') continue;
      bool ok1 = 1, ok2 = 1;
      for (int d = 1; d <= int(inf); d++) {
        if (!ok1 && !ok2) break;
        if (ok1) ok1 = judge(x, y - d) && judge(x - d, y);
        if (ok2) ok2 = judge(x, y + d) && judge(x - d, y);
        ans += ok1 && ok(x, y - d, x - d, y);
        ans += ok2 && ok(x, y + d, x - d, y);
      }
      ok1 = ok2 = 1;
      for (int d = 1; d <= int(inf); d++) {
        if (!ok1 && !ok2) break;
        if (ok1) ok1 = judge(x, y - d) && judge(x + d, y);
        if (ok2) ok2 = judge(x, y + d) && judge(x + d, y);
        ans += ok1 && ok(x, y - d, x + d, y);
        ans += ok2 && ok(x, y + d, x + d, y);
      }
    }
  for (int x = 1; x <= int(n); x++)
    for (int y = 1; y <= int(m); y++) {
      if (mp[x][y] == '1') continue;
      bool flag = 1;
      for (int d = 1; d <= int(inf); d++) {
        if (!flag) break;
        flag = judge(x, y - d) && judge(x, y + d) && (x - d >= 1);
        ans += flag && ok(x, y - d, x - d, y) && ok(x, y + d, x - d, y);
      }
      flag = 1;
      for (int d = 1; d <= int(inf); d++) {
        if (!flag) break;
        flag = judge(x, y - d) && judge(x, y + d) && (x + d <= n);
        ans += flag && ok(x, y - d, x + d, y) && ok(x, y + d, x + d, y);
      }
      flag = 1;
      for (int d = 1; d <= int(inf); d++) {
        if (!flag) break;
        flag = judge(x - d, y) && judge(x + d, y) && (y - d >= 1);
        ans += flag && ok(x - d, y, x, y - d) && ok(x + d, y, x, y - d);
      }
      flag = 1;
      for (int d = 1; d <= int(inf); d++) {
        if (!flag) break;
        flag = judge(x - d, y) && judge(x + d, y) && (y + d <= m);
        ans += flag && ok(x - d, y, x, y + d) && ok(x + d, y, x, y + d);
      }
    }
  printf("%d\n", ans);
}
