#include <bits/stdc++.h>
using namespace std;
template <typename T>
T power(T a, int n) {
  T res = 1;
  while (n) {
    if (n & 1) res = (res * a) % 1000000007;
    n >>= 1;
    a = (a * a) % 1000000007;
  }
  return res;
}
int n, m;
string str[500];
int row[500][500] = {0};
int col[500][500] = {0};
int diag1[1000][500] = {0};
int diag2[1000][500] = {0};
int main() {
  cin >> n >> m;
  for (int i = (0); i < (n); i++) {
    cin >> str[i];
  }
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      row[i][j] = row[i][j - 1];
      if (str[i - 1][j - 1] == '1') {
        row[i][j]++;
      }
    }
  }
  for (int j = (1); j < (m + 1); j++) {
    for (int i = (1); i < (n + 1); i++) {
      col[j][i] = col[j][i - 1];
      if (str[i - 1][j - 1] == '1') {
        col[j][i]++;
      }
    }
  }
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      if (i == 1 || j == m) {
        diag1[i][j] = (str[i - 1][j - 1] == '1' ? 1 : 0);
      } else {
        diag1[i][j] = diag1[i - 1][j + 1];
        if (str[i - 1][j - 1] == '1') {
          diag1[i][j]++;
        }
      }
    }
  }
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      if (i == 1 || j == 1) {
        diag2[i][j] = (str[i - 1][j - 1] == '1' ? 1 : 0);
      } else {
        diag2[i][j] = diag2[i - 1][j - 1];
        if (str[i - 1][j - 1] == '1') {
          diag2[i][j]++;
        }
      }
    }
  }
  int c = 0, x, y;
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      if (str[i - 1][j - 1] == '1') continue;
      for (int k = (j + 1); k < (m + 1); k++) {
        if (str[i - 1][k - 1] == '1') break;
        if ((k - j) % 2 == 0) {
          x = i + (k - j) / 2;
          y = j + (k - j) / 2;
          if (x <= n && (diag1[x][y] == diag1[i - 1][k + 1]) &&
              (diag2[x][y] == diag2[i - 1][j - 1])) {
            c++;
          }
          x = i - (k - j) / 2;
          if (x >= 1 && (diag1[i][j] == diag1[x - 1][y + 1]) &&
              (diag2[i][k] == diag2[x - 1][y - 1])) {
            c++;
          }
        }
        x = i + (k - j);
        y = j;
        if (x <= n && (diag1[x][y] == diag1[i - 1][k + 1]) &&
            (col[j][x] == col[j][i - 1])) {
          c++;
        }
        y = k;
        if (x <= n && (col[k][x] == col[k][i - 1]) &&
            (diag2[x][y] == diag2[i - 1][j - 1])) {
          c++;
        }
        x = i - (k - j);
        y = j;
        if (x >= 1 && (diag2[i][k] == diag2[x - 1][y - 1]) &&
            (col[j][i] == col[y][x - 1])) {
          c++;
        }
        y = k;
        if (x >= 1 && (diag1[i][j] == diag1[x - 1][y + 1]) &&
            (col[k][i] == col[y][x - 1])) {
          c++;
        }
      }
      for (int k = (i + 1); k < (n + 1); k++) {
        if (str[k - 1][j - 1] == '1') break;
        if ((k - i) % 2 == 0) {
          x = i + (k - i) / 2;
          y = j - (k - i) / 2;
          if (y >= 1 && (diag1[x][y] == diag1[i - 1][j + 1]) &&
              (diag2[k][j] == diag2[x - 1][y - 1])) {
            c++;
          }
          y = j + (k - i) / 2;
          if (y <= m && (diag1[k][j] == diag1[x - 1][y + 1]) &&
              (diag2[x][y] == diag2[i - 1][j - 1])) {
            c++;
          }
        }
      }
    }
  }
  cout << c;
  return 0;
}
