#include <bits/stdc++.h>
using namespace std;
int n, res;
char ch[2005][2005];
bool x[2005], y[2005], a[2005], b[2005];
int main() {
  int i, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ch[i];
    for (j = 0; j < n; j++) ch[i][j] -= '0';
  }
  for (i = n - 1; i > 0; i--) {
    for (j = 0; j < i; j++) {
      if (ch[i][j] ^ x[i] ^ y[j]) {
        res++;
        x[i] ^= 1;
        y[j] ^= 1;
      }
    }
  }
  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[i] ^ b[j] ^ ch[i][j]) {
        res++;
        a[i] ^= 1;
        b[j] ^= 1;
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (a[i] ^ b[i] ^ x[i] ^ y[i] ^ ch[i][i]) res++;
  }
  cout << res << endl;
}
