#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
const string task = "";
template <class T>
T sqr(T x) {
  return x * x;
}
const int nmax = 2100;
int a[nmax][nmax];
char s[nmax][nmax];
int n, res;
int x[nmax], y[nmax];
int main() {
  int n;
  cin >> n;
  gets(s[0]);
  for (int i = 0; i < (int)(n); i++) gets(s[i]);
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) a[i][j] = s[i][j] - '0';
  int res = 0;
  memset(x, 0, sizeof x);
  memset(y, 0, sizeof y);
  for (int i = n - 1; i > 0; i--) {
    for (int j = 0; i + j < n; j++) {
      int now = a[i + j][j] + x[i + j] + y[j];
      now = now & 1;
      if (now) {
        res++;
        x[i + j]++;
        y[j]++;
      }
    }
  }
  for (int i = 0; i < (int)(n); i++) a[i][i] = (a[i][i] + x[i] + y[i]) & 1;
  memset(x, 0, sizeof x);
  memset(y, 0, sizeof y);
  for (int i = n - 1; i > 0; i--) {
    for (int j = 0; i + j < n; j++) {
      int now = a[j][i + j] + x[j] + y[i + j];
      now = now & 1;
      if (now) {
        res++;
        y[i + j]++;
        x[j]++;
      }
    }
  }
  for (int i = 0; i < (int)(n); i++) a[i][i] = (a[i][i] + x[i] + y[i]) & 1;
  for (int i = 0; i < (int)(n); i++)
    if (a[i][i] == 1) res++;
  cout << res << endl;
  return 0;
}
