#include <bits/stdc++.h>
using namespace std;
int n, m;
int cnt[405][405], dl[405][405], dr[405][405];
int main() {
  string a;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a;
    for (int j = 0; j < m; ++j) cnt[i][j + 1] = a[j] == '0' ? 1 : 0;
  }
  memset(dl, 0, sizeof(dl));
  memset(dr, 0, sizeof(dr));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) dl[i][j] = dl[i - 1][j - 1] + cnt[i][j];
  for (int i = 1; i <= n; ++i)
    for (int j = m; j > 0; --j) dr[i][j] = dr[i - 1][j + 1] + cnt[i][j];
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (!cnt[i][j]) continue;
      for (int k = 1; cnt[i - k][j] && cnt[i][j - k]; ++k)
        if (dr[i][j - k] - dr[i - k - 1][j + 1] == k + 1) ans++;
      for (int k = 1; cnt[i + k][j] && cnt[i][j + k]; ++k)
        if (dr[i + k][j] - dr[i - 1][j + k + 1] == k + 1) ans++;
      for (int k = 1; cnt[i - k][j] && cnt[i][j + k]; ++k)
        if (dl[i][j + k] - dl[i - k - 1][j - 1] == k + 1) ans++;
      for (int k = 1; cnt[i + k][j] && cnt[i][j - k]; ++k)
        if (dl[i + k][j] - dl[i - 1][j - k - 1] == k + 1) ans++;
      for (int k = 1; cnt[i - k][j] && cnt[i + k][j]; ++k)
        if (dr[i][j - k] - dr[i - k - 1][j + 1] == k + 1 &&
            dl[i + k][j] - dl[i - 1][j - k - 1] == k + 1)
          ans++;
      for (int k = 1; cnt[i + k][j] && cnt[i - k][j]; ++k)
        if (dl[i][j + k] - dl[i - k - 1][j - 1] == k + 1 &&
            dr[i + k][j] - dr[i - 1][j + k + 1] == k + 1)
          ans++;
      for (int k = 1; cnt[i][j - k] && cnt[i][j + k]; ++k)
        if (dr[i][j - k] - dr[i - k - 1][j + 1] == k + 1 &&
            dl[i][j + k] - dl[i - k - 1][j - 1] == k + 1)
          ans++;
      for (int k = 1; cnt[i][j + k] && cnt[i][j - k]; ++k)
        if (dr[i + k][j] - dr[i - 1][j + k + 1] == k + 1 &&
            dl[i + k][j] - dl[i - 1][j - k - 1] == k + 1)
          ans++;
    }
  cout << ans << endl;
  return 0;
}
