#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, w, e, r, t, y = 0, c, v, e1;
  cin >> q >> w;
  int **a = new int *[400], **s = new int *[400], **d, f[400][401];
  for (e = 0; e < 400; e++) {
    a[e] = new int[400];
    s[e] = new int[400];
  }
  char i;
  for (e = 0; e < q; e++)
    for (r = 0; r < w; r++) {
      cin >> i;
      if (i == '1')
        a[e][r] = 1;
      else
        a[e][r] = 0;
    }
  for (t = 0; t < 4; t++) {
    for (e = 0; e < q; e++)
      for (r = 0; r < w; r++) s[r][q - e - 1] = a[e][r];
    e = q;
    q = w;
    w = e;
    d = a;
    a = s;
    s = d;
    for (e = 0; e < q; e++) {
      f[e][0] = 0;
      for (r = 0; r < w; r++) f[e][r + 1] = f[e][r] + a[e][r];
    }
    for (e = 0; e < q; e++)
      for (r = 0; r < w; r++)
        if (a[e][r] == 0) {
          for (e1 = e + 1, c = r, v = r + 1; (e1 < q) && (v < w); e1++, v++) {
            if ((a[e1][c]) || (a[e1][v])) break;
            if (f[e1][v] - f[e1][c] == 0) y++;
          }
          for (e1 = e + 1, c = r - 1, v = r + 1;
               (e1 < q) && ((v < w) && (c >= 0)); e1++, c--, v++) {
            if ((a[e1][c]) || (a[e1][v])) break;
            if (f[e1][v] - f[e1][c] == 0) y++;
          }
        }
  }
  cout << y;
  return 0;
}
