#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[55][55];
int b[55][55];
int main()
{
     ios_base::sync_with_stdio(0);
     cout.tie(0);cin.tie(0);

     int n, m; cin >> m >> n;
     for(int i = 1; i <= m; i++){ // duyet hang
          for(int j = 1; j <= n; j++){ // duyet cot
               cin >> a[i][j]; // phan tu hang thu i va cot thu j
               b[i][j] = a[i][j];
          }
     }

     for(int i = 1; i <= m; i++){
          for(int j = 1; j <= n; j++){
               if(a[i][j] == 0){
                    for(int k = 1; k <= n; k++){ // cot
                         b[i][k] = 0;
                    }
                    for(int k = 1; k <= m; k++){ // hang
                         b[k][j] = 0;
                    }
               }
          }
     }

     int ans = 0;
     for(int i = 1; i <= m; i++){ // duyet hang
          for(int j = 1; j <= n; j++){ // duyet cot
               if(b[i][j] == 1) ans++;
          }
     }
     cout << ans;
}










