#include <bits/stdc++.h>
using namespace std;
int n, sol = 0;
string ss;
int fld[2003][2002];
int lzyc[2003];
void solve() {
  int lzy = 0;
  for (int i = 0; i < n; i++) {
    lzy = 0;
    for (int j = n - 1; j > i; j--) {
      if (lzy > 0) fld[i][j] = 1 - fld[i][j];
      if (lzyc[j] > 0) fld[i][j] = 1 - fld[i][j];
      if (fld[i][j] == 1) {
        lzy = 1 - lzy;
        lzyc[j] = 1 - lzyc[j];
        sol++;
        fld[i][j] = 0;
      }
    }
    if (lzy) fld[i][i] = 1 - fld[i][i];
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ss;
    for (int j = 0; j < n; j++) {
      fld[i][j] = ss[j] - '0';
    }
  }
  solve();
  for (int i = 0; i < n; i++) {
    if (lzyc[i]) {
      fld[i][i] = 1 - fld[i][i];
      lzyc[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      fld[j][i] = fld[i][j];
    }
  }
  solve();
  for (int i = 0; i < n; i++) {
    if (lzyc[i]) {
      fld[i][i] = 1 - fld[i][i];
      lzyc[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    sol += fld[i][i];
  }
  cout << sol << endl;
}
