#include <bits/stdc++.h>
using namespace std;
int n;
int a[2010][2010];
char s[2010][2010];
long long int b[2010], c[2010], d[2010];
int cnt;
long long int changes;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", &s[i][1]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) a[i][j] = s[i][j] - '0';
  for (int i = 0; i <= 1000; i++) b[i] = c[i] = 0;
  for (int i = 0; i <= 1000; i++) d[i] = 0;
  for (int i = 1; i <= n; i++) {
    changes = 0;
    for (int j = n; j > i; j--) {
      if (((changes + b[j]) % 2) != a[i][j]) {
        cnt++;
        b[j]++;
        d[i] = (d[i] + 1) % 2;
        d[j] = (d[j] + 1) % 2;
        changes++;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    changes = 0;
    for (int j = 1; j < i; j++) {
      if (((c[j] + changes) % 2) != a[i][j]) {
        cnt++;
        c[j]++;
        d[i] = (d[i] + 1) % 2;
        d[j] = (d[j] + 1) % 2;
        changes++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i][i] != d[i]) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
