#include <bits/stdc++.h>
using namespace std;
long long const M = 2000 + 10, M2 = 1e7 + 10, mod = 1e9 + 7, inf = 1e9 + 10,
                sq = 450;
long long a[M][M], ro[M], col[M], all[M];
int32_t main() {
  long long n, ans = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    string x;
    cin >> x;
    for (long long j = 0; j < x.size(); j++) {
      a[i][j + 1] = x[j] - '0';
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = n; j > i; j--) {
      long long good = col[j] xor ro[i];
      long long need = good xor a[i][j];
      ro[i] = ro[i] xor need;
      all[i] = all[i] xor need;
      col[j] = col[j] xor need;
      all[j] = all[j] xor need;
      ans += need;
    }
  }
  for (long long i = 1; i <= n; i++) col[i] = 0, ro[i] = 0;
  for (long long i = n; i >= 1; i--) {
    for (long long j = 1; j < i; j++) {
      long long good = col[j] xor ro[i];
      long long need = good xor a[i][j];
      ro[i] = ro[i] xor need;
      all[i] = all[i] = all[i] xor need;
      col[j] = col[j] xor need;
      all[j] = all[j] xor need;
      ans += need;
    }
  }
  for (long long i = 1; i <= n; i++) {
    ans += all[i] xor a[i][i];
  }
  cout << ans;
}
