#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[410][410];
int f[410][410][8];
int dx[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < (n); i++) scanf("%s", s[i]);
    memset(f, 0, sizeof(f));
    for (int i = 0; i < (n); i++) {
      for (int j = 0; j < (m); j++) {
        if (s[i][j] == '0') {
          for (int k = 0; k < (4); k++) {
            f[i][j][k] = 1;
            int ii = i + dx[k], jj = j + dy[k];
            if (ii >= 0 && ii < n && jj >= 0 && jj < m) {
              f[i][j][k] += f[ii][jj][k];
            }
          }
        }
      }
    }
    for (int i = n - 1; i >= 0; --i) {
      for (int j = m - 1; j >= 0; --j) {
        if (s[i][j] == '0') {
          for (int k = 4; k < 8; ++k) {
            f[i][j][k] = 1;
            int ii = i + dx[k], jj = j + dy[k];
            if (ii >= 0 && ii < n && jj >= 0 && jj < m) {
              f[i][j][k] += f[ii][jj][k];
            }
          }
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < (n); i++) {
      for (int j = 0; j < (m); j++) {
        if (s[i][j] == '1') continue;
        for (int k = 0; k < (8); k++) {
          int d = min(f[i][j][k], f[i][j][(k + 2) % 8]), ii = i, jj = j,
              kk = (k + 3) % 8;
          for (int t = 1; t < d; ++t) {
            ii += dx[k];
            jj += dy[k];
            assert(ii >= 0 && ii < n && jj >= 0 && jj < m);
            if (kk % 2 == 0) {
              if (f[ii][jj][kk] >= t + t + 1) ++ans;
            } else {
              if (f[ii][jj][kk] >= t + 1) ++ans;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
