/*
[templates]:
duipai
spjdp
compre
addhis
floor_sum
treedfs
matrix
network_flow
polynomial
lca
bitset
valuesgt
fenwick
erbitree
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//use ll instead of int.
#define f(i, a, b) for(int i = (a); i <= (b); i++)
#define cl(i, n) i.clear(),i.resize(n);
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 1e18;
//#define cerr if(false)cerr
//#define freopen if(false)freopen
mt19937 rng(time(0));
int rnd(int l, int r) {return rng() % (r-l+1) + l; }
#define watch(x) cerr << (#x) << ' '<<'i'<<'s'<<' ' << x << endl
void pofe(int number, int bitnum) {
string s; f(i, 0, bitnum) {s += char(number & 1) + '0'; number >>= 1; }
reverse(s.begin(), s.end()); cerr << s << endl;
return;
}
template <typename TYP> void cmax(TYP &x, TYP y) {if(x < y) x = y;}
template <typename TYP> void cmin(TYP &x, TYP y) {if(x > y) x = y;}
//调不出来给我对拍!
//use std::array.
const int N = 1000;
char a[N + 10][N + 10];
int cntt[N + 10], cnttt[N + 10];
signed main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
//freopen();
//freopen();
//time_t start = clock();
//think twice,code once.
//think once,debug forever.
int n, m; cin >> n >> m;
f(i, 1, n) f(j, 1, m) cin >> a[i][j];
int ans = 0;
f(i, 1, n) {
int cnt = 0; f(j, 1, m) cnt += a[i][j] == '0';
cntt[i] = cnt;
}
f(i, 1, m) {
int cnt = 0; f(j, 1, n) cnt += a[j][i] == '0';
cnttt[i] = cnt;
}
f(i, 1, n) ans += cntt[i] > 0;
f(i, 1, m) ans += cnttt[i] > 0;
f(i, 1, n) f(j, 1, m) ans -= cntt[i] == 1 && cnttt[j] == 1 && a[i][j] == '0';
cout << (int)(ans + 1) << endl;
//time_t finish = clock();
//cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
return 0;
}