#include <bits/stdc++.h>
using namespace std;
bool solve() {
  vector<vector<int>> mat;
  int n, m;
  char c;
  cin >> n >> m;
  mat.resize(n, vector<int>(m));
  for (int i(0); i < n; i++) {
    for (int j(0); j < m; j++) {
      cin >> c;
      mat[i][j] = c - '0';
    }
  }
  vector<vector<long long>> col(m, vector<long long>(n, 0)),
      str(n, vector<long long>(m, 0));
  vector<vector<long long>> d1(n + m - 1, vector<long long>(min(n, m), 0)),
      d2 = d1;
  vector<vector<int>> id1(n, vector<int>(m, -1)), id2 = id1;
  for (int i(0); i < n; i++) {
    for (int j(0); j < m; j++)
      str[i][j] = (j ? str[i][j - 1] : 0) + mat[i][j],
      col[j][i] = (i ? col[j][i - 1] : 0) + mat[i][j];
  }
  for (int i(0); i < n + m - 1; i++) {
    long long sum = 0;
    int x, y, q = 0;
    if (i >= n)
      x = n - 1, y = i - n + 1;
    else
      x = i, y = 0;
    while (x >= 0 && y < m)
      sum += mat[x][y], d1[i][q] = sum, id1[x][y] = q, x--, y++, q++;
    sum = 0;
    q = 0;
    if (i >= n)
      x = n - 1, y = m - 1 - (i - n + 1);
    else
      x = i, y = m - 1;
    while (x >= 0 && y >= 0)
      sum += mat[x][y], d2[i][q] = sum, id2[x][y] = q, x--, y--, q++;
  }
  long long ans = 0;
  for (int i(0); i < n; i++) {
    for (int j(0); j < m; j++) {
      if (mat[i][j]) continue;
      long long X = ans;
      int x, id, l, r;
      x = 0;
      while (1) {
        if (i - x < 0) break;
        if (j - x < 0) break;
        if (mat[i - x][j]) break;
        if (mat[i][j - x]) break;
        id = i - x + j;
        l = id1[i - x][j];
        r = id1[i][j - x];
        if (d1[id][r] - (l ? d1[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      x = 0;
      while (1) {
        if (i - x < 0) break;
        if (j + x >= m) break;
        if (mat[i - x][j]) break;
        if (mat[i][j + x]) break;
        id = i - x + m - 1 - j;
        l = id2[i][j + x];
        r = id2[i - x][j];
        if (d2[id][r] - (l ? d2[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      x = 0;
      while (1) {
        if (i + x >= n) break;
        if (j - x < 0) break;
        if (mat[i + x][j]) break;
        if (mat[i][j - x]) break;
        id = i + m - 1 - (j - x);
        l = id2[i + x][j];
        r = id2[i][j - x];
        if (d2[id][r] - (l ? d2[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      x = 0;
      while (1) {
        if (i + x >= n) break;
        if (j + x >= m) break;
        if (mat[i][j + x]) break;
        if (mat[i + x][j]) break;
        id = i + x + j;
        l = id1[i + x][j];
        r = id1[i][j + x];
        if (d1[id][r] - (l ? d1[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      x = 0;
      while (1) {
        if (i - x < 0) break;
        if (j - x < 0) break;
        if (j + x >= m) break;
        if (mat[i - x][j - x]) break;
        if (mat[i - x][j + x]) break;
        id = i - x;
        l = j - x;
        r = j + x;
        if (str[id][r] - (l ? str[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      x = 0;
      while (1) {
        if (j + x >= m) break;
        if (i - x < 0) break;
        if (i + x >= n) break;
        if (mat[i - x][j + x]) break;
        if (mat[i + x][j + x]) break;
        id = j + x;
        l = i - x;
        r = i + x;
        if (col[id][r] - (l ? col[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      x = 0;
      while (1) {
        if (j + x >= m) break;
        if (j - x < 0) break;
        if (i + x >= n) break;
        if (mat[i + x][j + x]) break;
        if (mat[i + x][j - x]) break;
        id = i + x;
        l = j - x;
        r = j + x;
        if (str[id][r] - (l ? str[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      x = 0;
      while (1) {
        if (i - x < 0) break;
        if (i + x >= n) break;
        if (j - x < 0) break;
        if (mat[i - x][j - x]) break;
        if (mat[i + x][j - x]) break;
        id = j - x;
        l = i - x;
        r = i + x;
        if (col[id][r] - (l ? col[id][l - 1] : 0)) {
        } else
          ans++;
        x++;
      }
      ans -= 8;
    }
  }
  cout << ans << '\n';
  return true;
}
int main() {
  solve();
  return 0;
}
