#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 60;
long long toInt(string s) {
  long long res;
  stringstream ss;
  ss << s;
  ss >> res;
  return res;
}
string toString(long long n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
vector<string> fdst;
long long ans;
long long flip_col[2010];
long long flip_jiku[2010];
void run() {
  long long n;
  cin >> n;
  fdst = vector<string>(n);
  for (long long i = (0); i < (n); ++i) {
    cin >> fdst[i];
  }
  ans = 0;
  for (long long i = (0); i < (n); ++i) flip_col[i] = 0, flip_jiku[i] = 0;
  for (long long i = 0; i < n; i++) {
    long long flip = 0;
    for (long long j = n - 1; j > i; j--) {
      if (((flip_col[j] + flip) % 2) + '0' != fdst[i][j]) {
        ans++;
        flip++;
        flip_col[j]++;
        flip_jiku[j] += 1;
      }
    }
    flip_jiku[i] += flip % 2;
  }
  for (long long i = (0); i < (n); ++i) flip_col[i] = 0;
  for (long long i = n - 1; i >= 0; i--) {
    long long flip = 0;
    for (long long j = 0; j < i; j++) {
      if (((flip_col[j] + flip) % 2) + '0' != fdst[i][j]) {
        ans++;
        flip++;
        flip_col[j]++;
        flip_jiku[j] += 1;
      }
    }
    flip_jiku[i] += flip % 2;
  }
  for (long long i = (0); i < (n); ++i) {
    if ((flip_jiku[i] % 2) + '0' != fdst[i][i]) ans++;
  }
  cout << ans << endl;
}
int main(int argc, char *argv[]) {
  run();
  return 0;
}
