#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
bitset<N> row[N], col[N];
bitset<N> ones, B;
bool A[N][N];
inline void update(int x, int y) {
  row[x] ^= ones;
  col[y] ^= ones;
}
char s[N];
int main() {
  ones.set();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < n; j++) {
      A[i][j] = (s[j] == '1');
      col[j][i] = A[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if (row[i][j] ^ col[j][i]) {
        cnt++;
        update(i, j);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (row[i][i] ^ col[i][i]) B.set(i);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      row[i][j] = 0;
      col[j][i] = A[j][i];
    }
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if (row[i][j] ^ col[j][i]) {
        cnt++;
        update(i, j);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (B[i] ^ row[i][i] ^ col[i][i] ^ A[i][i]) cnt++;
  }
  printf("%d\n", cnt);
}
