#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2000 + 5;
int N, Picture[MaxN][MaxN], Rows[MaxN], Columns[MaxN];
int main(void) {
  scanf("%d", &N);
  getchar();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) Picture[i][j] = getchar() - '0';
    getchar();
  }
  int Sol = 0;
  for (int i = 0; i < N; i++)
    for (int j = N - 1; j > i; j--) {
      Picture[i][j] ^= Rows[i] ^ Columns[j];
      if (Picture[i][j]) {
        Sol++;
        Picture[i][j] ^= 1;
        Rows[i] ^= 1;
        Columns[j] ^= 1;
      }
    }
  for (int i = 0; i < N; i++) Picture[i][i] ^= Rows[i] ^ Columns[i];
  memset(Rows, 0, sizeof(Rows));
  memset(Columns, 0, sizeof(Columns));
  for (int i = N; i >= 0; i--)
    for (int j = 0; j < i; j++) {
      Picture[i][j] ^= Rows[i] ^ Columns[j];
      if (Picture[i][j]) {
        Sol++;
        Picture[i][j] ^= 1;
        Rows[i] ^= 1;
        Columns[j] ^= 1;
      }
    }
  for (int i = 0; i < N; i++) {
    Picture[i][i] ^= Rows[i] ^ Columns[i];
    if (Picture[i][i]) Sol++;
  }
  printf("%d\n", Sol);
  return 0;
}
