#include <bits/stdc++.h>
using namespace std;
int n, m;
int table[400][400];
int tmp[400][400];
int prefix_horizontal[400][401];
int prefix_left_side_down[400][401];
int prefix_top_side_down[400][401];
int ans;
void get_input() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    string row;
    cin >> row;
    for (int j = 0; j < m; ++j) table[i][j] = row[j] - '0';
  }
}
void compute_prefix_horizontal() {
  for (int r = 0; r < n; ++r) {
    prefix_horizontal[r][0] = 0;
    for (int i = 1; i <= m; ++i)
      prefix_horizontal[r][i] = prefix_horizontal[r][i - 1] + table[r][i - 1];
  }
}
void compute_prefix_left_side_down() {
  for (int r = 0; r < n; ++r) {
    prefix_left_side_down[r][0] = 0;
    for (int i = 1; i <= m && r + i <= n; ++i)
      prefix_left_side_down[r][i] =
          prefix_left_side_down[r][i - 1] + table[r + i - 1][i - 1];
  }
}
void compute_prefix_top_side_down() {
  for (int c = 0; c < m; ++c) {
    prefix_top_side_down[c][0] = 0;
    for (int i = 1; i <= n && c + i <= m; ++i)
      prefix_top_side_down[c][i] =
          prefix_top_side_down[c][i - 1] + table[i - 1][c + i - 1];
  }
}
void rotate() {
  for (int r = 0; r < n; ++r)
    for (int c = 0; c < m; ++c) tmp[m - c - 1][r] = table[r][c];
  swap(table, tmp);
  swap(n, m);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  get_input();
  for (int iter = 0; iter < 4; ++iter) {
    compute_prefix_horizontal();
    compute_prefix_left_side_down();
    compute_prefix_top_side_down();
    for (int r = 0; r < n; ++r)
      for (int c = 0; c < m; ++c)
        if (table[r][c] == 0) {
          for (int len = 1; (r - len >= 0) && (c - len >= 0) && (c + len < m);
               ++len)
            if (table[r - len][c - len] == 1 || table[r - len][c + len] == 1)
              break;
            else if (prefix_horizontal[r - len][c + len + 1] -
                         prefix_horizontal[r - len][c - len] ==
                     0)
              ans++;
          for (int len = 1; (r - len >= 0) && (c + len < m); ++len)
            if ((table[r - len][c] == 1) || (table[r][c + len] == 1))
              break;
            else if (r - len <= c) {
              if (prefix_top_side_down[c - (r - len)][r + 1] -
                      prefix_top_side_down[c - (r - len)][r - len] ==
                  0)
                ans++;
            } else if (prefix_left_side_down[r - len - c][c + len + 1] -
                           prefix_left_side_down[r - len - c][c] ==
                       0)
              ans++;
        }
    rotate();
  }
  cout << ans << endl;
  return 0;
}
