#include <bits/stdc++.h>
using namespace std;
const int maxn = 400 + 10;
int n, m;
int mat[maxn][maxn];
int a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], d[maxn][maxn];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      char ch;
      scanf(" %c", &ch);
      mat[i][j] = ch - '0';
    }
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= n; ++j) {
      int _i = j, _j = i + j - 1;
      if (_j > m) break;
      a[_i][_j] = a[_i - 1][_j - 1] + mat[_i][_j];
    }
  for (int i = 2; i <= n - 1; ++i)
    for (int j = i; j <= n; ++j) {
      int _i = j, _j = 1 + j - i;
      if (_j > m) break;
      a[_i][_j] = a[_i - 1][_j - 1] + mat[_i][_j];
    }
  for (int i = 1; i <= m; ++i)
    for (int j = n; j >= 1; --j) {
      int _i = j, _j = i + (n - j);
      if (_j > m) break;
      b[_i][_j] = b[_i + 1][_j - 1] + mat[_i][_j];
    }
  for (int i = n - 1; i >= 2; --i)
    for (int j = i; j >= 1; --j) {
      int _i = j, _j = 1 + (i - j);
      if (_j > m) break;
      b[_i][_j] = b[_i + 1][_j - 1] + mat[_i][_j];
    }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (mat[i][j]) continue;
      for (int l = 1; i - l >= 1 && j + l <= m; ++l) {
        if (mat[i - l][j] || mat[i][j + l]) break;
        if (a[i][j + l] - a[i - l - 1][j - 1] == 0) {
          ans++;
        }
      }
      for (int l = 1; j + l <= m && i + l <= n; ++l) {
        if (mat[i][j + l] || mat[i + l][j]) break;
        if (b[i][j + l] - b[i + l + 1][j - 1] == 0) {
          ans++;
        }
      }
      for (int l = 1; i + l <= n && j - l >= 1; ++l) {
        if (mat[i + l][j] || mat[i][j - l]) break;
        if (a[i + l][j] - a[i - 1][j - l - 1] == 0) {
          ans++;
        }
      }
      for (int l = 1; j - l >= 1 && i - l >= 1; ++l) {
        if (mat[i - l][j] || mat[i][j - l]) break;
        if (b[i - l][j] - b[i + 1][j - l - 1] == 0) {
          ans++;
        }
      }
      for (int l = 1; i - l >= 1 && i + l <= n && j + l <= m; ++l) {
        if (mat[i - l][j] || mat[i + l][j]) break;
        if (mat[i][j + l]) continue;
        if (a[i][j + l] - a[i - l - 1][j - 1] == 0 &&
            b[i][j + l] - b[i + l + 1][j - 1] == 0)
          ans++;
      }
      for (int l = 1; i - l >= 1 && i + l <= n && j - l >= 1; ++l) {
        if (mat[i + l][j] || mat[i - l][j]) break;
        if (mat[i][j - l]) continue;
        if (a[i + l][j] - a[i - 1][j - l - 1] == 0 &&
            b[i - l][j] - b[i + 1][j - l - 1] == 0)
          ans++;
      }
      for (int l = 1; j - l >= 1 && j + l <= m && i - l >= 1; ++l) {
        if (mat[i][j + l] || mat[i][j - l]) break;
        if (mat[i - l][j]) continue;
        if (a[i][j + l] - a[i - l - 1][j - 1] == 0 &&
            b[i - l][j] - b[i + 1][j - l - 1] == 0)
          ans++;
      }
      for (int l = 1; j - l >= 1 && j + l <= m && i + l <= n; ++l) {
        if (mat[i][j - l] || mat[i][j + l]) break;
        if (mat[i + l][j]) continue;
        if (a[i + l][j] - a[i - 1][j - l - 1] == 0 &&
            b[i][j + l] - b[i + l + 1][j - 1] == 0)
          ans++;
      }
    }
  cout << ans << endl;
  return 0;
}
