#include <bits/stdc++.h>
using namespace std;
const int N = 2222;
int d[N][4];
int a[N][N];
int n;
int ans = 0;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (auto i = (0); i < (n); i++) {
    string s;
    cin >> s;
    for (auto j = (0); j < (n); j++) a[i][j] = s[j] - '0';
  }
  for (auto i = (n - 1); i >= (0); i--) {
    for (auto j = (0); j < (i); j++) {
      int pixel = d[i][3] ^ d[j][2];
      if (pixel != a[i][j]) {
        ++ans;
        d[i][3] ^= 1;
        d[j][2] ^= 1;
      }
    }
  }
  for (auto i = (0); i < (n); i++) {
    for (auto j = (n - 1); j >= (i + 1); j--) {
      int pixel = d[i][1] ^ d[j][0];
      if (pixel != a[i][j]) {
        ++ans;
        d[i][1] ^= 1;
        d[j][0] ^= 1;
      }
    }
  }
  for (auto i = (0); i < (n); i++) {
    int pixel = d[i][1] ^ d[i][3] ^ d[i][0] ^ d[i][2];
    if (pixel != a[i][i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}
