#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
long long mod = 1000000007LL;
long long mod2 = 998244353LL;
int n;
bool mat[2005][2005];
int cntr[2005], cntc[2005];
int cnt[2005];
int main() {
  cin >> n;
  memset(mat, false, sizeof(mat));
  memset(cntr, 0, sizeof(cntr));
  memset(cntc, 0, sizeof(cntc));
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    for (int j = 1; j <= n; ++j) {
      mat[i][j] = (s[j - 1] == '1');
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = n; j >= i; --j) {
      if (j == i) continue;
      bool x = ((cntr[i] + cntc[j]) % 2 > 0);
      if (mat[i][j] != x) {
        ans++;
        cntr[i]++;
        cntc[j]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cnt[i] += cntr[i] + cntc[i];
  }
  memset(cntr, 0, sizeof(cntr));
  memset(cntc, 0, sizeof(cntc));
  for (int i = n; i >= 1; --i) {
    for (int j = 1; j <= i; ++j) {
      if (j == i) continue;
      bool x = ((cntr[i] + cntc[j]) % 2 > 0);
      if (mat[i][j] != x) {
        ans++;
        cntr[i]++;
        cntc[j]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cnt[i] += cntr[i] + cntc[i];
  }
  for (int i = 1; i <= n; ++i) {
    bool x = (cnt[i] % 2 > 0);
    if (mat[i][i] != x) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
