#include <bits/stdc++.h>
using namespace std;
int const N = 400 + 20;
int n, m, a[N][N], ans, cnt[4][N][N];
bool f[8];
bool in(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > m) return 0;
  return 1;
}
void check(int a1, int b1, int a2, int b2, int idx, int dir) {
  if (in(a1, b1) && in(a2, b2) && !a[a1][b1] && !a[a2][b2]) {
    if (cnt[dir][a1][b1] == cnt[dir][a2][b2]) ans++;
  } else
    f[idx] = 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cnt[0][i][j] = cnt[0][i][j - 1] + a[i][j];
      cnt[1][i][j] = cnt[1][i - 1][j] + a[i][j];
      cnt[2][i][j] = cnt[2][i - 1][j - 1] + a[i][j];
      cnt[3][i][j] = cnt[3][i - 1][j + 1] + a[i][j];
    }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j]) continue;
      for (int k = 0; k < 8; k++) f[k] = 1;
      for (int k = 1; k < n; k++) {
        if (f[0]) check(i - k, j, i, j - k, 0, 3);
        if (f[1]) check(i - k, j, i, j + k, 1, 2);
        if (f[2]) check(i + k, j, i, j - k, 2, 2);
        if (f[3]) check(i + k, j, i, j + k, 3, 3);
        if (f[4]) check(i + k, j + k, i + k, j - k, 4, 0);
        if (f[5]) check(i + k, j + k, i - k, j + k, 5, 1);
        if (f[6]) check(i - k, j - k, i + k, j - k, 6, 1);
        if (f[7]) check(i - k, j - k, i - k, j + k, 7, 0);
      }
    }
  }
  return cout << ans << '\n', 0;
}
