#include <bits/stdc++.h>
using namespace std;
int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
double nf() {
  double a;
  scanf("%lf", &a);
  return a;
}
char sbuf[100005];
string ns() {
  scanf("%s", sbuf);
  return sbuf;
}
long long nll() {
  long long a;
  scanf("%lld", &a);
  return a;
}
template <class T>
void out(T a, T b) {
  bool first = true;
  for (T i = a; i != b; ++i) {
    if (!first) printf(" ");
    first = false;
    cout << *i;
  }
  printf("\n");
}
template <class T>
void outl(T a, T b) {
  for (T i = a; i != b; ++i) {
    cout << *i << "\n";
  }
}
int n, m;
bool v1[2005];
bool h1[2005];
bool v2[2005];
bool h2[2005];
int main() {
  int i, j, k;
  vector<string> v;
  n = ni();
  for (i = (0); i < (((n))); ++i) v.push_back(ns());
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < i; ++j) {
      if ((v[i][j] == '0') != (v1[i] && h1[j] || !v1[i] && !h1[j])) {
        v1[i] = !v1[i];
        h1[j] = !h1[j];
        ++ans;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j > i; --j) {
      if ((v[i][j] == '0') != (v2[i] && h2[j] || !v2[i] && !h2[j])) {
        v2[i] = !v2[i];
        h2[j] = !h2[j];
        ++ans;
      }
    }
  }
  for (i = (0); i < (((n))); ++i) {
    int q = 0;
    if (v1[i]) ++q;
    if (h1[i]) ++q;
    if (v2[i]) ++q;
    if (h2[i]) ++q;
    if (!!(q % 2) != (v[i][i] == '1')) {
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}
