#include <bits/stdc++.h>
using namespace std;
const int N = 4e2 + 5;
int m, n, ans;
bool t[N][N];
string s;
pair<pair<int, int>, pair<int, int> > is[N][N];
pair<int, int> isD[N][N], isU[N][N];
void upd(int x, int y) {
  is[x][y].second.second = -1;
  is[x][y].first.second = -1;
  is[x][y].second.first = n;
  is[x][y].first.first = m;
  for (int i = y; i < m; i++)
    if (t[x][i]) {
      is[x][y].first.first = i;
      break;
    }
  for (int i = y; i >= 0; i--)
    if (t[x][i]) {
      is[x][y].first.second = i;
      break;
    }
  for (int i = x; i < n; i++)
    if (t[i][y]) {
      is[x][y].second.first = i;
      break;
    }
  for (int i = x; i >= 0; i--)
    if (t[i][y]) {
      is[x][y].second.second = i;
      break;
    }
  isD[x][y].first = n;
  isD[x][y].second = n;
  int counter = 0, i = 0;
  for (i = 1; i + x < n && i + y < m && !t[i + x][i + y]; i++) counter = i;
  isD[x][y].first = counter;
  counter = 0;
  for (i = 1; y + i < m && x - i > -1 && !t[x - i][y + i]; i++) counter = i;
  isD[x][y].second = counter;
  isU[x][y].first = n;
  isU[x][y].second = n;
  counter = 0;
  i = 0;
  for (i = 1; x - i > -1 && y - i > -1 && !t[x - i][y - i]; i++) counter = i;
  isU[x][y].first = counter;
  counter = 0;
  for (i = 1; y - i > -1 && x + i < n && !t[x + i][y - i]; i++) counter = i;
  isU[x][y].second = counter;
  if (t[x][y]) {
    isU[x][y].second = 0;
    isU[x][y].first = 0;
    isD[x][y].second = 0;
    isD[x][y].first = 0;
  }
}
int ret(int a, int b, int p) {
  int cnt = 0, x = 0;
  x = is[a][b].first.first;
  bool is1 = (b + p < x);
  x = is[a][b].second.first;
  bool is2 = (a + p < x);
  a += p;
  b += p;
  x = is[a][b].first.second;
  bool is3 = (b - p > x);
  x = is[a][b].second.second;
  bool is4 = (a - p > x);
  a -= p;
  b -= p;
  bool is5 = (isD[a][b].first >= p);
  bool is6 = (isD[a + p][b].second >= p);
  if (is6 && is2 && is1) cnt++;
  if (is6 && is4 && is3) cnt++;
  if (is5 && is1 && is4) cnt++;
  if (is5 && is2 && is3) cnt++;
  return cnt;
}
int check(int x, int y) {
  int cnt = 0;
  for (int i = 1; i + x < n && i + y < m; i++) {
    int e = ret(x, y, i);
    cnt += e;
  }
  return cnt;
}
int countD(int x, int y) {
  int cnt = 0;
  for (int i = x + 2; i < is[x][y].second.first; i += 2) {
    int q = (i - x) / 2;
    bool is1 = (isD[x][y].first >= q);
    bool is2 = (isD[i][y].second >= q);
    if (is1 && is2 && x + q < n && y + q < m) {
      cnt++;
    }
    is1 = (isU[x][y].second >= q);
    is2 = (isU[i][y].first >= q);
    if (is1 && is2 && x + q < n && y + q > -1) {
      cnt++;
    }
  }
  return cnt;
}
int FAKCOUNTING(int x, int y) {
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if ((x + i < n && y + i < m && y - i > -1)) {
      bool is1 = (isU[x][y].second >= i);
      bool is2 = (isD[x][y].first >= i);
      bool is3 = (is[x + i][y - i].first.first > y + i);
      if (is1 && is2 && is3) cnt++;
    }
  }
  for (int i = 1; i < n; i++) {
    if ((x - i < n && y + i < m && y - i > -1)) {
      bool is1 = (isU[x][y].first >= i);
      bool is2 = (isD[x][y].second >= i);
      bool is3 = (is[x - i][y - i].first.first > y + i);
      if (is1 && is2 && is3) cnt++;
    }
  }
  return cnt;
}
int main(int argc, const char* argv[]) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      t[i][j] = s[j] - '0';
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      upd(i, j);
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int x = check(i, j) + countD(i, j) + FAKCOUNTING(i, j);
      ans += x;
    }
  cout << ans;
  return 0;
}
