#include <bits/stdc++.h>
using namespace std;
int ary[210][210];
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> ary[i][j];
    }
  }
  int res = 0;
  if (H <= 2) {
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        res += ary[i][j];
      }
    }
  }
  cout << res << endl;
  return 0;
}
