#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > D;
int main(int argc, char **argv) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    D.push_back(vector<int>());
    for (int j = 0; j < m; j++) {
      D[D.size() - 1].push_back(t[j] == '1');
    }
  }
  int c0[400][400], c1[400][400];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int k;
      for (k = 0;; k++) {
        if (i + k >= n || j + k >= m || D[i + k][j + k]) break;
      }
      c0[i][j] = k;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int k;
      for (k = 0;; k++) {
        if (i + k >= n || j - k < 0 || D[i + k][j - k]) break;
      }
      c1[i][j] = k;
    }
  int s = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (D[i][j]) continue;
      for (int k = 1;; k++) {
        if (j + k >= m || i + k >= n || D[i][j + k] || D[i + k][j]) break;
        if (c1[i][j + k] > k) s += 1;
      }
      for (int k = 1;; k++) {
        if (j - k < 0 || i + k >= n || D[i][j - k] || D[i + k][j]) break;
        if (c0[i][j - k] > k) s += 1;
      }
      for (int k = 1;; k++) {
        if (j + k >= m || i - k < 0 || D[i][j + k] || D[i - k][j]) break;
        if (c0[i - k][j] > k) s += 1;
      }
      for (int k = 1;; k++) {
        if (j - k < 0 || i - k < 0 || D[i][j - k] || D[i - k][j]) break;
        if (c1[i - k][j] > k) s += 1;
      }
      for (int k = 1;; k++) {
        if (i + k >= n || j + k >= m || j - k < 0 || D[i][j + k] || D[i][j - k])
          break;
        if (c0[i][j - k] > k && c1[i][j + k] > k) s += 1;
      }
      for (int k = 1;; k++) {
        if (i - k < 0 || j + k >= m || j - k < 0 || D[i][j + k] || D[i][j - k])
          break;
        if (c0[i - k][j] > k && c1[i - k][j] > k) s += 1;
      }
      for (int k = 1;; k++) {
        if (i - k < 0 || i + k >= n || j + k >= m || D[i - k][j] || D[i + k][j])
          break;
        if (c0[i - k][j] > k && c1[i][j + k] > k) s += 1;
      }
      for (int k = 1;; k++) {
        if (i - k < 0 || i + k >= n || j - k >= m || D[i - k][j] || D[i + k][j])
          break;
        if (c0[i][j - k] > k && c1[i - k][j] > k) s += 1;
      }
    }
  cout << s << endl;
  return 0;
}
