#include <bits/stdc++.h>
using namespace std;
int n;
int a[2100][2100];
char cur;
int r[2100], c[2100];
int diag[2100];
int main() {
  scanf("%d\n", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%c", &cur);
      if (cur == '0')
        a[i][j] = 0;
      else
        a[i][j] = 1;
    }
    scanf("\n");
  }
  int res = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = n - 1; j > i; --j) {
      int color = (r[i] + c[j]) % 2;
      if (color != a[i][j]) {
        ++res;
        ++c[j];
        ++r[i];
      }
    }
  }
  for (int i = 0; i < n; ++i) diag[i] = (r[i] + c[i]) % 2;
  memset(r, 0, sizeof(r));
  memset(c, 0, sizeof(c));
  for (int i = n - 1; i > 0; --i) {
    for (int j = 0; j < i; ++j) {
      int color = (r[i] + c[j]) % 2;
      if (color != a[i][j]) {
        ++res;
        ++c[j];
        ++r[i];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    diag[i] = (diag[i] + r[i] + c[i]) % 2;
    if (diag[i] != a[i][i]) ++res;
  }
  cout << res << endl;
  return 0;
}
