#include <bits/stdc++.h>
using namespace std;
const int N = 2100;
int n, nrm;
char a[N][N];
int v[N][N];
char t;
void calc() {
  int i, j, col[N], col2[N];
  for (i = 1; i <= n; ++i) col[i] = col2[i] = 0;
  for (i = 1; i < n; ++i) {
    int l = 0;
    for (j = n; j > i; --j) {
      int st = l ^ col[j];
      if (a[i][j] - '0' != st) {
        ++nrm;
        l = 1 - l;
        col[j] = 1 - col[j];
      }
    }
    v[i][i] ^= l;
  }
  for (i = n; i > 1; --i) {
    int l = 0;
    for (j = 1; j < i; ++j) {
      int st = l ^ col2[j];
      if (a[i][j] - '0' != st) {
        ++nrm;
        l = 1 - l;
        col2[j] = 1 - col2[j];
      }
    }
    v[i][i] ^= l;
  }
  for (i = 1; i <= n; ++i) {
    if (col[i] > 1 || col2[i] > 1)
      while (1)
        ;
    if (a[i][i] - '0' != v[i][i] ^ col[i] ^ col2[i]) ++nrm;
  }
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%s", a[i] + 1);
  }
  calc();
  cout << nrm;
  return 0;
}
