#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, res = 0;
  cin >> n >> m;
  vector<string> G(n);
  for (int i = 0; i < n; i++) cin >> G[i];
  vector<vector<int> > row(n, vector<int>(m, -1));
  vector<vector<int> > col(n, vector<int>(m, -1));
  vector<vector<int> > diar(n, vector<int>(m, -1));
  vector<vector<int> > dial(n, vector<int>(m, -1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (G[i][j] == '1') continue;
      row[i][j] = col[i][j] = diar[i][j] = dial[i][j] = 0;
      if (j != 0) {
        row[i][j] = row[i][j - 1] + 1;
      }
      if (i != 0) {
        col[i][j] = col[i - 1][j] + 1;
      }
      if (i != 0 && j != 0) {
        diar[i][j] = diar[i - 1][j - 1] + 1;
      }
      if (i != 0 && j != m - 1) {
        dial[i][j] = dial[i - 1][j + 1] + 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 1; k < n; k++) {
        if (i - k >= 0 && j - k >= 0 && row[i][j] >= k && col[i][j] >= k &&
            dial[i][j - k] >= k)
          res++;
        if (i + k < n && j - k >= 0 && row[i][j] >= k && col[i + k][j] >= k &&
            diar[i + k][j] >= k)
          res++;
        if (i + k < n && j + k < m && row[i][j + k] >= k &&
            col[i + k][j] >= k && dial[i + k][j] >= k)
          res++;
        if (i - k >= 0 && j + k < m && row[i][j + k] >= k && col[i][j] >= k &&
            diar[i][j + k] >= k)
          res++;
        if (i - k >= 0 && j - k >= 0 && col[i][j] >= k && dial[i][j - k] >= k &&
            i + k < n && j - k >= 0 && col[i + k][j] >= k &&
            diar[i + k][j] >= k)
          res++;
        if (i + k < n && j - k >= 0 && row[i][j] >= k && diar[i + k][j] >= k &&
            i + k < n && j + k < m && row[i][j + k] >= k && dial[i + k][j] >= k)
          res++;
        if (i + k < n && j + k < m && col[i + k][j] >= k &&
            dial[i + k][j] >= k && i - k >= 0 && j + k < m && col[i][j] >= k &&
            diar[i][j + k] >= k)
          res++;
        if (i - k >= 0 && j + k < m && row[i][j + k] >= k &&
            diar[i][j + k] >= k && i - k >= 0 && j - k >= 0 && row[i][j] >= k &&
            dial[i][j - k] >= k)
          res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}
