#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
template <class T>
T gcd(T x, T y) {
  while (T t = x % y) x = y, y = t;
  return y;
}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;
bool isdig(char x) { return x >= '0' && x <= '9'; }
bool isup(char x) { return x >= 'A' && x <= 'Z'; }
bool isdown(char x) { return x >= 'a' && x <= 'z'; }
bool islet(char x) { return isup(x) || isdown(x); }
int N, M;
char str[405][405];
void get_data() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) scanf("%s", str[i + 1] + 1);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++) str[i][j] -= '0';
}
int hsum[405][405], vsum[405][405];
int isum[405][405], jsum[405][405];
void get_sum() {
  memset(hsum, 0, sizeof(hsum));
  memset(vsum, 0, sizeof(vsum));
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      hsum[i][j] = hsum[i][j - 1] + str[i][j];
      vsum[i][j] = vsum[i - 1][j] + str[i][j];
      isum[i][j] = isum[i - 1][j - 1] + str[i][j];
    }
    for (int j = M; j >= 1; j--) {
      jsum[i][j] = jsum[i - 1][j + 1] + str[i][j];
    }
  }
}
int cal_sum(int i0, int j0, int i1, int j1) {
  if (i0 == i1) {
    if (j0 > j1) swap(j0, j1);
    return hsum[i0][j1] - hsum[i0][j0 - 1];
  }
  if (j0 == j1) {
    if (i0 > i1) swap(i0, i1);
    return vsum[i1][j0] - vsum[i0 - 1][j0];
  }
  if (i0 > i1) {
    swap(i0, i1);
    swap(j0, j1);
  }
  if (j0 < j1) {
    return isum[i1][j1] - isum[i0 - 1][j0 - 1];
  } else {
    return jsum[i1][j1] - jsum[i0 - 1][j0 + 1];
  }
}
bool out(int i, int j) { return i < 1 || i > N || j < 1 || j > M; }
void run() {
  get_sum();
  int r = 0;
  int dir[8][2] = {-1, -1, -1, 0, -1, 1, 0, 1, 1, 1, 1, 0, 1, -1, 0, -1};
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++) {
      if (str[i][j] == 1) continue;
      for (int d = 0; d < 8; d++) {
        int d0 = d;
        int d1 = (d + 2) % 8;
        for (int k = 1;; k++) {
          int ii[2], jj[2];
          ii[0] = i + dir[d0][0] * k;
          jj[0] = j + dir[d0][1] * k;
          ii[1] = i + dir[d1][0] * k;
          jj[1] = j + dir[d1][1] * k;
          if (out(ii[0], jj[0]) || out(ii[1], jj[1]) ||
              str[ii[0]][jj[0]] == 1 || str[ii[1]][jj[1]] == 1)
            break;
          r += (cal_sum(ii[0], jj[0], ii[1], jj[1]) == 0);
        }
      }
    }
  cout << r << endl;
}
int main() {
  int t;
  t = 1;
  while (t--) {
    get_data();
    run();
  }
  return 0;
}
