#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
char buff[512][512];
int lr[1024][1024];
int td[1024][1024];
int lt[1024][1024];
int rt[1024][1024];
void init(int n, int m) {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      lr[i][j] = lr[i][j - 1] + (buff[i][j] == '1'),
      td[i][j] = td[i - 1][j] + (buff[i][j] == '1');
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      lt[i][j] = lt[i - 1][j - 1] + (buff[i][j] == '1');
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      rt[i][j] = rt[i - 1][j + 1] + (buff[i][j] == '1');
}
static inline int has_black(int x1, int y1, int x2, int y2) {
  if (x1 > x2) swap(x1, x2), swap(y1, y2);
  if (x1 == x2) {
    if (y1 > y2) swap(y1, y2);
    return lr[x1][y2] - lr[x1][y1 - 1] > 0;
  }
  if (y1 == y2) {
    return td[x2][y1] - td[x1 - 1][y1] > 0;
  }
  if (y1 > y2) {
    return rt[x2][y2] - rt[x1 - 1][y1 + 1] > 0;
  }
  return lt[x2][y2] - lt[x1 - 1][y1 - 1] > 0;
}
int main() {
  int n = Rint(), m = Rint();
  for (int i = 1; i <= n; ++i) scanf("%s", buff[i] + 1);
  init(n, m);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (buff[i][j] == '0') {
        for (int u = i + 1, v = j + 1; u <= n && v <= m; ++u, ++v) {
          if (buff[i][v] == '1' || buff[u][j] == '1') break;
          if (has_black(i, v, u, j)) continue;
          ++ans;
        }
        for (int u = i + 1, v = j - 1; u <= n && v > 0; ++u, --v) {
          if (buff[i][v] == '1' || buff[u][j] == '1') break;
          if (has_black(i, v, u, j)) continue;
          ++ans;
        }
        for (int u = i - 1, v = j - 1; u > 0 && v > 0; --u, --v) {
          if (buff[i][v] == '1' || buff[u][j] == '1') break;
          if (has_black(i, v, u, j)) continue;
          ++ans;
        }
        for (int u = i - 1, v = j + 1; u > 0 && v <= m; --u, ++v) {
          if (buff[i][v] == '1' || buff[u][j] == '1') break;
          if (has_black(i, v, u, j)) continue;
          ++ans;
        }
        for (int u = i + 1, d = 1; u <= n && j + d <= m && j - d > 0;
             ++u, ++d) {
          if (has_black(u, j - d, u, j + d)) continue;
          if (has_black(i, j, u, j + d)) continue;
          if (has_black(i, j, u, j - d)) continue;
          ++ans;
        }
        for (int u = i - 1, d = 1; u > 0 && j + d <= m && j - d > 0; --u, ++d) {
          if (has_black(u, j - d, u, j + d)) continue;
          if (has_black(i, j, u, j + d)) continue;
          if (has_black(i, j, u, j - d)) continue;
          ++ans;
        }
        for (int v = j + 1, d = 1; v <= m && i + d <= n && i - d > 0;
             ++v, ++d) {
          if (has_black(i - d, v, i + d, v)) continue;
          if (has_black(i, j, i - d, v)) continue;
          if (has_black(i, j, i + d, v)) continue;
          ++ans;
        }
        for (int v = j - 1, d = 1; v > 0 && i + d <= n && i - d > 0; --v, ++d) {
          if (has_black(i - d, v, i + d, v)) continue;
          if (has_black(i, j, i - d, v)) continue;
          if (has_black(i, j, i + d, v)) continue;
          ++ans;
        }
      }
  printf("%d\n", ans);
  return 0;
}
