#include <bits/stdc++.h>
using namespace std;
char in[405][405];
int R, C;
int ans[405][405][2][4];
int cx[] = {-1, 0, 1, 0}, cy[] = {0, 1, 0, -1};
int to_right[405][405];
int to_bot[405][405];
int to_right_bot[405][405];
int to_left_bot[405][405];
bool valid2(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first)
    swap(a, b);
  else if (a.first == b.first && a.second > b.second)
    swap(a, b);
  if (a.first == b.first) {
    return to_right[a.first][b.second] - to_right[a.first][a.second - 1] ==
           b.second - a.second + 1;
  } else if (a.second == b.second) {
    return to_bot[b.first][a.second] - to_bot[a.first - 1][a.second] ==
           b.first - a.first + 1;
  } else if (a.second > b.second) {
    return to_left_bot[b.first][b.second] -
               to_left_bot[a.first - 1][a.second + 1] ==
           a.second - b.second + 1;
  } else {
    return to_right_bot[b.first][b.second] -
               to_right_bot[a.first - 1][a.second - 1] ==
           b.second - a.second + 1;
  }
}
bool valid3(pair<int, int> a) {
  return a.first >= 1 && a.first <= R && a.second >= 1 && a.second <= C;
}
bool valid(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  return valid2(b, a) && valid2(b, c) && valid2(a, c);
}
int main() {
  scanf("%d %d", &R, &C);
  for (int i = 1; i <= R; i++) scanf("%s", in[i] + 1);
  for (int i = 1; i <= R; i++) {
    for (int j = 1; j <= C; j++) {
      to_right[i][j] = to_right[i][j - 1] + (in[i][j] == '0');
      to_bot[i][j] = to_bot[i - 1][j] + (in[i][j] == '0');
      to_right_bot[i][j] = to_right_bot[i - 1][j - 1] + (in[i][j] == '0');
    }
  }
  for (int i = 1; i <= R; i++) {
    for (int j = C; j >= 1; j--) {
      to_left_bot[i][j] = to_left_bot[i - 1][j + 1] + (in[i][j] == '0');
    }
  }
  pair<int, int> a, b, c;
  for (int i = 1; i <= R; i++) {
    for (int j = 1; j <= C; j++) {
      for (int di = 0; di < 4; di++) {
        for (int k = 1; k <= 400; k++) {
          a = pair<int, int>(i, j);
          b = pair<int, int>(i + cx[di] * k, j + cy[di] * k);
          c = pair<int, int>(i + cx[(di + 1) % 4] * k,
                             j + cy[(di + 1) % 4] * k);
          if (!valid3(a)) break;
          if (!valid3(b)) break;
          if (!valid3(c)) break;
          if (valid(a, b, c)) {
            ans[i][j][0][di]++;
          }
        }
        for (int k = 1; k <= 400; k++) {
          a = pair<int, int>(i + cx[(di + 3) % 4] * k,
                             j + cy[(di + 3) % 4] * k);
          b = pair<int, int>(i + cx[di] * k, j + cy[di] * k);
          c = pair<int, int>(i + cx[(di + 1) % 4] * k,
                             j + cy[(di + 1) % 4] * k);
          if (!valid3(a)) break;
          if (!valid3(b)) break;
          if (!valid3(c)) break;
          if (valid(a, b, c)) {
            ans[i][j][1][di]++;
          }
        }
      }
    }
  }
  long long ans1 = 0;
  for (int i = 1; i <= R; i++) {
    for (int j = 1; j <= C; j++) {
      for (int k = 0; k < 4; k++) {
        ans1 += ans[i][j][0][k] + ans[i][j][1][k];
      }
    }
  }
  cout << ans1 << endl;
  return 0;
}
