#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-8;
int calc(vector<string> &vs, int rb[], int cb[]) {
  int n = vs.size();
  int res = 0;
  for (int d = n - 1; d > 0; d--) {
    for (int r = 0; r < n; r++) {
      int c = r + d;
      if (c < 0 || c >= n) continue;
      if ((vs[r][c] == '1') ^ rb[r] ^ cb[c]) {
        res++;
        rb[r] ^= 1;
        cb[c] ^= 1;
      }
    }
  }
  return res;
}
int main() {
  istream &fin = cin;
  ostream &fout = cout;
  FILE *fpin = stdin;
  FILE *fpout = stdout;
  int n;
  fin >> n;
  vector<string> vs(n);
  for (int i = 0; i < n; i++) fin >> vs[i];
  int rb[2][2010], cb[2][2010];
  memset(rb, 0, sizeof(rb));
  memset(cb, 0, sizeof(cb));
  int res = 0;
  res += calc(vs, rb[0], cb[0]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      swap(vs[i][j], vs[j][i]);
    }
  }
  res += calc(vs, rb[1], cb[1]);
  for (int i = 0; i < n; i++) {
    if ((vs[i][i] == '1') ^ rb[0][i] ^ rb[1][i] ^ cb[0][i] ^ cb[1][i]) res++;
  }
  fout << res << endl;
}
