#include <bits/stdc++.h>
using namespace std;
vector<vector<bool> > a;
vector<int> cnt;
vector<int> cntx;
vector<int> cnty;
int main() {
  int n;
  cin >> n;
  a.resize(n);
  cntx.resize(n, 0);
  cnty.resize(n, 0);
  for (int i = 0; i < n; i++) {
    a[i].resize(n);
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) a[i][j] = (s[j] == '1');
  }
  int res = 0;
  cnt.resize(n, 0);
  for (int i = n - 1; i >= 0; i--) {
    int ry = 0;
    for (int j = 0; j < i; j++) {
      bool f = a[i][j];
      if (ry % 2 == 1) f = !f;
      if (cnt[j] % 2 == 1) f = !f;
      if (f) res++, ry++, cnt[j]++, cntx[j]++, cnty[i]++;
    }
  }
  for (int i = 0; i < n; i++) cnt[i] = 0;
  for (int i = 0; i < n; i++) {
    int ry = 0;
    for (int j = n - 1; j > i; j--) {
      bool f = a[i][j];
      if (ry % 2 == 1) f = !f;
      if (cnt[j] % 2 == 1) f = !f;
      if (f) res++, ry++, cnt[j]++, cntx[j]++, cnty[i]++;
    }
  }
  for (int i = 0; i < n; i++) {
    bool f = a[i][i];
    if (cntx[i] % 2 == 1) f = !f;
    if (cnty[i] % 2 == 1) f = !f;
    if (f) res++;
  }
  cout << res;
  return 0;
}
