#include <bits/stdc++.h>
using namespace std;
const int MAX = 4e2 + 10;
const int MAXS = 1e8 + 10;
char ar[MAX][MAX];
const int dir[8][2] = {{0, -1}, {-1, -1}, {-1, 0}, {-1, 1},
                       {0, 1},  {1, 1},   {1, 0},  {1, -1}};
const int dd[8] = {2, 1, 2, 1, 2, 1, 2, 1};
int cnt[MAX][MAX][8];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", ar[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int d = 0; d < 4; d++)
        if (ar[i][j] != '0')
          cnt[i][j][d] = 0;
        else
          cnt[i][j][d] = cnt[i + dir[d][0]][j + dir[d][1]][d] + 1;
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      for (int d = 4; d < 8; d++)
        if (ar[i][j] != '0')
          cnt[i][j][d] = 0;
        else
          cnt[i][j][d] = cnt[i + dir[d][0]][j + dir[d][1]][d] + 1;
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (ar[i][j] != '0') continue;
      for (int d1 = 0; d1 < 8; d1++) {
        int d2 = (d1 + 2) % 8;
        int d3 = (d2 + 1) % 8;
        int mx = min(cnt[i][j][d1], cnt[i][j][d2]);
        int x1 = i + dir[d1][0], y1 = j + dir[d1][1], ll = dd[d3];
        for (int l = 1; l < mx;
             l++, x1 += dir[d1][0], y1 += dir[d1][1], ll += dd[d3])
          if (cnt[x1][y1][d3] >= ll) ans++;
      }
    }
  printf("%d\n", ans);
}
