#include <bits/stdc++.h>
using namespace std;
bool row[2100];
bool col[2100];
bool tmp[2100];
bool ar[2100][2100];
int main() {
  int n, i, j, cnt;
  cin >> n;
  cnt = 0;
  for (i = 0; i < n; i++) {
    row[i] = col[i] = 0;
  }
  string line;
  for (i = 0; i < n; i++) {
    cin >> line;
    for (j = 0; j < n; j++) {
      ar[i][j] = line[j] - '0';
    }
  }
  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (ar[i][j] != (col[j] ^ row[i])) {
        col[j] = !col[j];
        row[i] = !row[i];
        cnt++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    tmp[i] = row[i] ^ col[i];
    row[i] = 0;
    col[i] = 0;
  }
  for (i = n - 1; i > 0; i--) {
    for (j = 0; j < i; j++) {
      if (ar[i][j] != (col[j] ^ row[i])) {
        col[j] = !col[j];
        row[i] = !row[i];
        cnt++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (ar[i][i] != (tmp[i] ^ row[i] ^ col[i])) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
