#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
int n;
string field[N];
int diag[N], horiz[N], vertic[N];
int solve() {
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if (horiz[i] ^ vertic[j] ^ (field[i][j] - '0')) {
        ret++;
        vertic[j] ^= 1;
        horiz[i] ^= 1;
      }
    }
  }
  for (int i = 0; i < n; i++) diag[i] ^= horiz[i] ^ vertic[i];
  return ret;
}
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> field[i];
  int ans = 0;
  ans += solve();
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) field[i][j] = field[j][i];
  memset(horiz, 0, sizeof(horiz));
  memset(vertic, 0, sizeof(vertic));
  ans += solve();
  for (int i = 0; i < n; i++)
    if ((field[i][i] - '0') ^ diag[i]) ans++;
  cout << ans << endl;
  return 0;
}
