#include <bits/stdc++.h>
using namespace std;
const int DOWN = 0, DIAG = 1, RIGHT = 2;
const int dx[8][2] = {{-1, 0}, {-1, 0}, {-1, 1}, {0, -1},
                      {-2, 0}, {2, 0},  {0, -2}, {0, 2}};
const int dy[8][2] = {{0, 1},  {-1, 1}, {0, 1},  {1, 0},
                      {-1, 1}, {1, -1}, {1, -1}, {-1, 1}};
const int dir[8] = {DIAG, RIGHT, DOWN, DIAG, DIAG, DIAG, DIAG, DIAG};
int n, m;
char matriz[410][410];
int cont[3][410][410];
void precalc();
bool limite(pair<int, int> a);
int find_cont(pair<int, int> p1, pair<int, int> p2, int k);
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", matriz[i]);
  }
  precalc();
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (matriz[i][j] == '0') {
        for (int k = 0; k < 8; k++) {
          pair<int, int> p1 = pair<int, int>(i + dx[k][0], j + dx[k][1]);
          pair<int, int> p2 = pair<int, int>(i + dy[k][0], j + dy[k][1]);
          int aux = 2;
          while (limite(p1) and limite(p2)) {
            if (k >= 4 &&
                matriz[p1.first - dx[k][0] / 2][p1.second - dx[k][1] / 2] ==
                    '1')
              break;
            if (find_cont(p1, p2, k) >= aux) {
              ans++;
            }
            p1.first += dx[k][0];
            p1.second += dx[k][1];
            p2.first += dy[k][0];
            p2.second += dy[k][1];
            aux++;
          }
        }
      }
  printf("%d\n", ans);
}
int find_cont(pair<int, int> p1, pair<int, int> p2, int k) {
  if (k != 5 && k != 7) {
    return cont[dir[k]][p1.first][p1.second];
  } else {
    return cont[dir[k]][p2.first][p2.second];
  }
}
void precalc() {
  int aux;
  for (int j = 0; j < m; j++) {
    aux = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (matriz[i][j] == '0')
        aux++;
      else
        aux = 0;
      cont[DOWN][i][j] = aux;
    }
  }
  for (int i = 0; i < n; i++) {
    aux = 0;
    for (int j = m - 1; j >= 0; j--) {
      if (matriz[i][j] == '0')
        aux++;
      else
        aux = 0;
      cont[RIGHT][i][j] = aux;
    }
  }
  for (int j = 0; j < m; j++) {
    aux = 0;
    for (int i = n - 1, jj = j; jj >= 0; i--, jj--) {
      if (matriz[i][jj] == '0')
        aux++;
      else
        aux = 0;
      cont[DIAG][i][jj] = aux;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    aux = 0;
    for (int j = m - 1, iii = i; iii >= 0; j--, iii--) {
      if (matriz[iii][j] == '0')
        aux++;
      else
        aux = 0;
      cont[DIAG][iii][j] = aux;
    }
  }
}
bool limite(pair<int, int> a) {
  if (a.first < 0 || a.first >= n || a.second < 0 || a.second >= m) {
    return false;
  } else if (matriz[a.first][a.second] == '1') {
    return false;
  } else {
    return true;
  }
}
