#include <bits/stdc++.h>
using namespace std;
const int oo = 2000000009;
const double eps = 1e-9;
const int mx = 2003;
int n;
int col[mx];
char m[mx][mx];
int mat[mx][mx];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) scanf("%s", m[i]);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) mat[i][j] = m[i][j] - '0';
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    int f = 0;
    for (int j = n - 1; j > i; --j) {
      int nw = (mat[i][j] ^ f ^ col[j]);
      ans += nw;
      f ^= nw;
      col[j] ^= nw;
    }
    mat[i][i] ^= f ^ col[i];
  }
  memset(col, 0, sizeof(col));
  for (int i = n - 1; i >= 0; --i) {
    int f = 0;
    for (int j = 0; j < (i); ++j) {
      int nw = (mat[i][j] ^ f ^ col[j]);
      ans += nw;
      f ^= nw;
      col[j] ^= nw;
    }
    mat[i][i] ^= f ^ col[i];
  }
  for (int i = 0; i < (n); ++i) ans += mat[i][i];
  printf("%d\n", ans);
  return 0;
}
