#include <bits/stdc++.h>
const int N = 2010;
const int inf = 0x3f3f3f3f;
using namespace std;
char s[N][N];
int b[N][N], a[N][N];
int col[N];
int main() {
  int n;
  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++) b[i][j] = s[i][j] - '0';
  for (int i = 1, sum = 0; i <= n; i++) {
    sum = 0;
    for (int j = n; j > i; j--) {
      if ((col[j] + sum) % 2 == b[i][j])
        a[i][j] = 0;
      else
        a[i][j] = 1, col[j]++, sum++;
    }
  }
  memset(col, 0, sizeof(col));
  for (int i = n, sum = 0; i >= 1; i--) {
    sum = 0;
    for (int j = 1; j < i; j++) {
      if ((col[j] + sum) % 2 == b[i][j])
        a[i][j] = 0;
      else
        a[i][j] = 1, col[j]++, sum++;
    }
  }
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 1; j <= n; j++) cnt += a[i][j] + a[j][i];
    if (cnt % 2 != b[i][i]) a[i][i] = 1;
  }
  int ret = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) ret += a[i][j];
  printf("%d\n", ret);
  return 0;
}
