#include <bits/stdc++.h>
using namespace std;
int n, m;
char str[403][403];
int rs[403][403], cs[403][403];
int cornar[403][403], co2[403][403];
int ans = 0;
void print() {
  cout << "--------start---------" << endl;
  for (int i = 0; i < n; i++) printf("%s\n", str[i]);
  cout << "--------end---------" << endl;
}
void precal() {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      rs[i][j] = str[i][j] - '0';
      if (j) rs[i][j] += rs[i][j - 1];
    }
  }
  for (j = 0; j < m; j++) {
    for (i = 0; i < n; i++) {
      cs[j][i] = str[i][j] - '0';
      if (i) cs[j][i] += cs[j][i - 1];
    }
  }
  for (j = 0; j < m; j++) {
    cornar[0][j] = str[0][j] - '0';
  }
  for (i = 0; i < n; i++) {
    cornar[i][0] = str[i][0] - '0';
    co2[i][0] = str[i][0] - '0';
  }
  for (j = 0; j < m; j++) co2[n - 1][j] = str[n - 1][j] - '0';
  for (i = 1; i < n; i++) {
    for (j = 1; j < m; j++)
      cornar[i][j] = cornar[i - 1][j - 1] + (str[i][j] - '0');
  }
  for (j = 1; j < m; j++) {
    for (i = n - 2; i > 0; i--)
      co2[i][j] = co2[i + 1][j - 1] + (str[i][j] - '0');
  }
}
void rotate_it() {
  int i, j;
  for (i = 0; i < max(n, m); i++)
    for (j = i + 1; j < max(n, m); j++) swap(str[i][j], str[j][i]);
  swap(n, m);
  for (i = 0; i < n / 2; i++)
    for (j = 0; j < m; j++) swap(str[i][j], str[n - i - 1][j]);
}
void solve() {
  int i, j, k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (str[i][j] == '1') continue;
      int x = max(n, m);
      for (k = 1; k <= x; k++) {
        int x1 = i - k, y1 = j, x2 = i, y2 = j + k;
        if (x1 < 0 || y2 >= m || str[x1][y1] == '1' || str[x2][y2] == '1')
          break;
        if (cornar[i - k][j] != cornar[i][j + k]) continue;
        ans++;
      }
      for (k = 1; k <= x; k++) {
        int x1 = i - k, y1 = j - k, x2 = i - k, y2 = j + k;
        if (x1 < 0 || y1 < 0 || y2 >= m || str[x1][y1] == '1' ||
            str[x2][y2] == '1')
          break;
        if (rs[x1][y1] != rs[x1][y2]) continue;
        ans++;
      }
    }
  }
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", str[i]);
  precal();
  solve();
  rotate_it();
  precal();
  solve();
  rotate_it();
  precal();
  solve();
  rotate_it();
  precal();
  solve();
  cout << ans << endl;
}
