#include <bits/stdc++.h>
using namespace std;
const int MAXN = 405;
char mp[MAXN][MAXN];
int xie[MAXN][MAXN];
int eix[MAXN][MAXN];
int hen[MAXN][MAXN];
int shu[MAXN][MAXN];
int n, m;
const int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
const int Dir[4][2] = {1, 1, 1, -1, -1, -1, -1, 1};
int calc(int x, int y) {
  int cnt = 0;
  for (int d = 0; d < 4; d++) {
    int x1 = x, y1 = y;
    int x2 = x, y2 = y;
    for (int i = 1;; i++) {
      x1 += dir[d][0];
      y1 += dir[d][1];
      x2 += dir[(d - 1 + 4) % 4][0];
      y2 += dir[(d - 1 + 4) % 4][1];
      if (mp[x1][y1] != '0' || mp[x2][y2] != '0') {
        break;
      }
      if (d == 0) {
        if (eix[x1][y1] >= i + 1) {
          ++cnt;
        }
      } else if (d == 1) {
        if (xie[x1][y1] >= i + 1) {
          ++cnt;
        }
      } else if (d == 2) {
        if (eix[x2][y2] >= i + 1) {
          ++cnt;
        }
      } else {
        if (xie[x2][y2] >= i + 1) {
          ++cnt;
        }
      }
    }
  }
  for (int d = 0; d < 4; d++) {
    int x1 = x, y1 = y;
    int x2 = x, y2 = y;
    for (int i = 1;; i++) {
      x1 += Dir[d][0];
      y1 += Dir[d][1];
      x2 += Dir[(d - 1 + 4) % 4][0];
      y2 += Dir[(d - 1 + 4) % 4][1];
      if (mp[x1][y1] != '0' || mp[x2][y2] != '0') {
        break;
      }
      if (d == 0) {
        if (shu[x1][y1] >= i * 2 + 1) {
          ++cnt;
        }
      } else if (d == 1) {
        if (hen[x2][y2] >= i * 2 + 1) {
          ++cnt;
        }
      } else if (d == 2) {
        if (shu[x2][y2] >= i * 2 + 1) {
          ++cnt;
        }
      } else {
        if (hen[x1][y1] >= i * 2 + 1) {
          ++cnt;
        }
      }
    }
  }
  return cnt;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", mp[i] + 1);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] == '1') {
        hen[i][j] = 0;
      } else {
        hen[i][j] = hen[i][j - 1] + 1;
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      if (mp[i][j] == '1') {
        shu[i][j] = 0;
      } else {
        shu[i][j] = shu[i - 1][j] + 1;
      }
    }
  }
  for (int i = 2; i <= n + m; i++) {
    for (int j = 1, last = 0; j < i; j++) {
      if (j < 1 || j > n || (i - j) < 1 || (i - j) > m) {
        continue;
      }
      if (mp[j][i - j] == '1') {
        xie[j][i - j] = 0;
      } else {
        xie[j][i - j] = last + 1;
      }
      last = xie[j][i - j];
    }
  }
  for (int i = 1 - n; i <= m - 1; i++) {
    for (int j = 1, last = 0; j <= n; j++) {
      if (j < 1 || j > n || j + i < 1 || j + i > m) {
        continue;
      }
      if (mp[j][i + j] == '1') {
        eix[j][i + j] = 0;
      } else {
        eix[j][i + j] = last + 1;
      }
      last = eix[j][i + j];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] != '1') {
        ans += calc(i, j);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
