#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
int n, m;
int i, j, k, l;
char c[N][N];
int sr[N][N], su[N][N];
int ans, x, y;
int inv;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%s", &c[i]);
  ans = 0;
  x = 0;
  y = n - 1;
  for (; x || y;) {
    inv = (x ? su[x - 1][y] : 0) + sr[x][y + 1] + (c[x][y] == '1');
    su[x][y] = (x ? su[x - 1][y] : 0);
    sr[x][y] = sr[x][y + 1];
    if (inv & 1) {
      su[x][y]++;
      sr[x][y]++;
      ++ans;
    }
    ++x;
    ++y;
    if (y == n) {
      y = n - x - 1;
      x = 0;
    }
  }
  for (x = y = 0; x < n; x++, y++) {
    inv = (x ? su[x - 1][y] : 0) + sr[x][y + 1] + (c[x][y] == '1');
    su[x][y] = (x ? su[x - 1][y] : 0);
    sr[x][y] = sr[x][y + 1];
    c[x][y] = (inv & 1) + '0';
  }
  for (i = 0; i < n; ++i)
    for (j = i; j < n; ++j) {
      swap(c[i][j], c[j][i]);
    }
  memset(su, 0, sizeof(su));
  ;
  memset(sr, 0, sizeof(sr));
  ;
  x = 0;
  y = n - 1;
  for (; x || y;) {
    inv = (x ? su[x - 1][y] : 0) + sr[x][y + 1] + (c[x][y] == '1');
    su[x][y] = (x ? su[x - 1][y] : 0);
    sr[x][y] = sr[x][y + 1];
    if (inv & 1) {
      su[x][y]++;
      sr[x][y]++;
      ++ans;
    }
    ++x;
    ++y;
    if (y == n) {
      y = n - x - 1;
      x = 0;
    }
    if (x == 0 && y == 0) break;
  }
  for (x = y = 0; x < n; x++, y++) {
    inv = (x ? su[x - 1][y] : 0) + sr[x][y + 1] + (c[x][y] == '1');
    su[x][y] = (x ? su[x - 1][y] : 0);
    sr[x][y] = sr[x][y + 1];
    if (inv & 1) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
