#include <bits/stdc++.h>
using namespace std;
int i, j, k, m, n;
long long t1, t2, x1, x2, t0, a1, a2;
const double eps = 1e-10;
double ans = 1e100, ivs;
int x[2005], y[2005], xy[4005], z[4005], yx[4005];
short sh[2005][2005], sv[2005][2005], s[2005][2005];
char p[2005];
int main() {
  scanf("%d\n", &n);
  for (i = 0; i < n; i++) {
    gets(p);
    for (j = 0; j < n; j++)
      if (p[j] == '1') {
        s[i + 1][j + 1] = 1;
      }
  }
  int ans = 0;
  for (i = 1; i <= n; i++)
    for (j = n; j > i; j--) {
      sh[i][j] ^= sh[i][j + 1];
      sv[i][j] ^= sv[i - 1][j];
      if (sh[i][j] ^ sv[i][j] != s[i][j]) {
        sh[i][j] ^= 1;
        sv[i][j] ^= 1;
        s[i][j] = 1;
        ans++;
      } else
        s[i][j] = 0;
    }
  for (i = n; i >= 1; i--)
    for (j = 1; j < i; j++) {
      sh[i][j] ^= sh[i][j - 1];
      sv[i][j] ^= sv[i + 1][j];
      if (sh[i][j] ^ sv[i][j] != s[i][j]) {
        sh[i][j] ^= 1;
        sv[i][j] ^= 1;
        ans++;
        s[i][j] = 1;
      } else
        s[i][j] = 0;
    }
  for (i = 1; i <= n; i++) {
    j = i;
    sh[i][j] ^= sh[i][j - 1] ^ sh[i][j + 1];
    sv[i][j] ^= sv[i + 1][j] ^ sv[i - 1][j];
    if (sh[i][j] ^ sv[i][j] != s[i][j]) {
      sh[i][j] ^= 1;
      sv[i][j] ^= 1;
      ans++;
      s[i][j] = 1;
    } else
      s[i][j] = 0;
  }
  cout << ans << endl;
  return 0;
}
