#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > horiz, vert, upDiag, downDiag;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<string> grid(n + 1, string(m + 1, '.'));
  for (int i = (0); i < ((n)); ++i) {
    for (int j = (0); j < ((m)); ++j) cin >> grid[i + 1][j + 1];
  }
  ++n;
  ++m;
  horiz.resize(n, vector<int>(m));
  vert.resize(n, vector<int>(m));
  downDiag.resize(n, vector<int>(m));
  upDiag.resize(n, vector<int>(m));
  for (int i = (1); i < (n); ++i)
    for (int j = (1); j < (m); ++j) {
      horiz[i][j] = horiz[i][j - 1] + grid[i][j] - '0';
      vert[i][j] = vert[i - 1][j] + grid[i][j] - '0';
      downDiag[i][j] = downDiag[i - 1][j - 1] + grid[i][j] - '0';
      upDiag[i][j] = upDiag[i - 1][j + 1] + grid[i][j] - '0';
    }
  int cnt = 0;
  for (int i = (1); i < (n); ++i)
    for (int j = (1); j < (m); ++j) {
      if (grid[i][j] != '0') continue;
      for (int k = i - 1; k > 0; --k) {
        if (grid[k][j] == '1') break;
        int const len = i - k;
        if (j + len < m && horiz[i][j + len] == horiz[i][j - 1] &&
            downDiag[i][j + len] == downDiag[k - 1][j - 1])
          ++cnt;
        if (j - len > 0 && horiz[i][j - len - 1] == horiz[i][j] &&
            upDiag[i][j - len] == upDiag[k - 1][j + 1])
          ++cnt;
        if (j + len < m && horiz[k][j + len] == horiz[k][j - 1] &&
            upDiag[i][j] == upDiag[k - 1][j + len + 1])
          ++cnt;
        if (j - len > 0 && horiz[k][j - len - 1] == horiz[k][j] &&
            downDiag[i][j] == downDiag[k - 1][j - len - 1])
          ++cnt;
        if (~len & 1) {
          if (i - len / 2 > 0 && j + len / 2 < m &&
              downDiag[i - len / 2][j + len / 2] == downDiag[k - 1][j - 1] &&
              upDiag[i][j] == upDiag[i - len / 2 - 1][j + len / 2 + 1])
            ++cnt;
          if (i - len / 2 > 0 && j - len / 2 > 0 &&
              upDiag[i - len / 2][j - len / 2] == upDiag[k - 1][j + 1] &&
              downDiag[i][j] == downDiag[i - len / 2 - 1][j - len / 2 - 1])
            ++cnt;
        }
      }
      for (int k = j - 1; k > 0; --k) {
        if (grid[i][k] == '1') break;
        int const len = j - k;
        if (len & 1) continue;
        if (i - len / 2 > 0 && j - len / 2 > 0 &&
            upDiag[i][k] == upDiag[i - len / 2 - 1][j - len / 2 + 1] &&
            downDiag[i][j] == downDiag[i - len / 2 - 1][j - len / 2 - 1])
          ++cnt;
        if (i + len / 2 < n && j - len / 2 > 0 &&
            upDiag[i + len / 2][j - len / 2] == upDiag[i - 1][j + 1] &&
            downDiag[i + len / 2][j - len / 2] == downDiag[i - 1][k - 1])
          ++cnt;
      }
    }
  cout << cnt << endl;
  return 0;
}
