#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
inline int two(int n) { return 1 << n; }
long long extgcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
long long modpow(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
const int sz = 420;
bool a[sz][sz];
long long amt[sz][sz][8];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ifstream in("input.txt");
  ofstream out("output.txt");
  int n, m;
  long long cnt = 0;
  string s;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) a[i][j] = (s[j] == '0');
  }
  for (int i = 0; i < n; i++) {
    int lst = m;
    for (int j = m - 1; j >= 0; j--) {
      if (a[i][j])
        amt[i][j][0] = lst - j - 1;
      else
        lst = j;
    }
    lst = -1;
    for (int j = 0; j < m; j++) {
      if (a[i][j])
        amt[i][j][4] = j - lst - 1;
      else
        lst = j;
    }
  }
  for (int j = 0; j < m; j++) {
    int lst = n;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i][j])
        amt[i][j][6] = lst - i - 1;
      else
        lst = i;
    }
    lst = -1;
    for (int i = 0; i < n; i++) {
      if (a[i][j])
        amt[i][j][2] = i - lst - 1;
      else
        lst = i;
    }
  }
  for (int s = 0; s < n + m - 1; s++) {
    int x, y;
    if (s < m) {
      x = 0;
      y = s;
    } else {
      x = s - m + 1;
      y = m - 1;
    }
    int prev = -1, iter = 0;
    while (x + iter < n && y - iter >= 0) {
      if (a[x + iter][y - iter])
        amt[x + iter][y - iter][1] = iter - prev - 1;
      else
        prev = iter;
      iter++;
    }
    x += iter - 1, y -= (iter - 1);
    iter = 0;
    prev = -1;
    while (x - iter >= 0 && y + iter < m) {
      if (a[x - iter][y + iter])
        amt[x - iter][y + iter][5] = iter - prev - 1;
      else
        prev = iter;
      iter++;
    }
  }
  for (int s = 0; s < n + m - 1; s++) {
    int x, y, iter = 0, prev = -1;
    if (s < m) {
      x = 0;
      y = m - s - 1;
    } else {
      x = s - m + 1;
      y = 0;
    }
    while (x + iter < n && y + iter < m) {
      if (a[x + iter][y + iter])
        amt[x + iter][y + iter][3] = iter - prev - 1;
      else
        prev = iter;
      iter++;
    }
    x += (iter - 1);
    y += (iter - 1);
    prev = 0;
    iter = -1;
    while (x - iter >= 0 && y - iter >= 0) {
      if (a[x - iter][y - iter])
        amt[x - iter][y - iter][7] = iter - prev - 1;
      else
        prev = iter;
      iter++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int d = 2; d <= amt[i][j][0]; d += 2) {
        if (amt[i][j][1] >= d / 2 && amt[i][j + d][3] >= d / 2) cnt++;
        if (amt[i][j][7] >= d / 2 && amt[i][j + d][5] >= d / 2) cnt++;
      }
      for (int d = 2; d <= amt[i][j][2]; d += 2) {
        if (amt[i][j][1] >= d / 2 && amt[i - d][j][7] >= d / 2) cnt++;
        if (amt[i][j][3] >= d / 2 && amt[i - d][j][5] >= d / 2) cnt++;
      }
      for (int d = 1; d <= amt[i][j][1]; d++) {
        if (amt[i][j][0] >= d && amt[i - d][j + d][6] >= d) cnt++;
        if (amt[i][j][2] >= d && amt[i - d][j + d][4] >= d) cnt++;
      }
      for (int d = 1; d <= amt[i][j][3]; d++) {
        if (amt[i][j][2] >= d && amt[i - d][j - d][0] >= d) cnt++;
        if (amt[i][j][4] >= d && amt[i - d][j - d][6] >= d) cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
