#include <bits/stdc++.h>
using namespace std;
const int N = 405;
const int dx[8] = {0, -1, -1, -1, 0, 1, 1, 1};
const int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int n, m, a[N][N], f[N][N][8], ans;
char ch;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> ch;
      a[i][j] = ch - '0';
    }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      for (int k = 0; k < 4; ++k) {
        int x = i, y = j;
        while (x > 0 && x <= n && y > 0 && y <= m && a[x][y] == 0)
          x += dx[k], y += dy[k];
        f[i][j][k] = (i - x != 0 ? i - x : j - y);
      }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j] == 0)
        for (int k = 0; k < 8; ++k) {
          int l = (k + 2) % 8, w = (k + 3) % 4;
          for (int t = 1; t < min(n, m); ++t) {
            int xp = i + t * dx[k], yp = j + t * dy[k], xq = i + t * dx[l],
                yq = j + t * dy[l];
            if (xp <= 0 || xp > n || yp <= 0 || yp > m || xq <= 0 || xq > n ||
                yq <= 0 || yq > m)
              break;
            if (a[xp][yp] == 1 || a[xq][yq] == 1) break;
            if (k >= 1 && k <= 4) {
              if ((dx[w] == 0 || f[xq][yq][w] > (xp - xq) / dx[w]) &&
                  (dy[w] == 0 || f[xq][yq][w] > (yp - yq) / dy[w]))
                ans++;
            } else {
              if ((dx[w] == 0 || f[xp][yp][w] > (xq - xp) / dx[w]) &&
                  (dy[w] == 0 || f[xp][yp][w] > (yq - yp) / dy[w]))
                ans++;
            }
          }
        }
  cout << ans << "\n";
  return 0;
}
