#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, an;
int f[2010], a[2010][2010];
char p[2010][2010];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%s", p[i] + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) a[i][j] = p[i][j] == '1';
  for (j = 1; j <= n; j++) {
    int s = 0;
    for (i = n; i > j; i--) {
      if (a[i][j] ^ f[i] ^ s) {
        f[i] ^= 1;
        s ^= 1;
        an++;
      }
    }
    a[j][j] ^= s;
  }
  for (j = 1; j <= n; j++) a[j][j] ^= f[j], f[j] = 0;
  for (j = n; j; j--) {
    int s = 0;
    for (i = 1; i <= j - 1; i++) {
      if (a[i][j] ^ f[i] ^ s) {
        f[i] ^= 1;
        s ^= 1;
        an++;
      }
    }
    a[j][j] ^= s;
  }
  for (j = 1; j <= n; j++)
    if (a[j][j] ^ f[j]) an++;
  printf("%d\n", an);
  return 0;
}
