#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000000000000000000;
long long mod = 1000000000;
long double pi = 3.141592653589793238;
void pls() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long N = 2e3 + 2;
long long n;
long long mat[N][N];
void solve() {
  cin >> n;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char x;
      cin >> x;
      if (x == '1') mat[i][j] = 1;
    }
  }
  vector<long long> row1(n, 0), col1(n, 0), row2(n, 0), col2(n, 0);
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      long long val = mat[i][j];
      if (row1[i] ^ col1[j]) val ^= 1;
      if (val) {
        res++;
        row1[i] ^= 1;
        col1[j] ^= 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      long long val = mat[i][j];
      if (row2[i] ^ col2[j]) val ^= 1;
      if (val) {
        res++;
        row2[i] ^= 1;
        col2[j] ^= 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    long long val = mat[i][i];
    if ((row1[i] ^ col1[i]) ^ (row2[i] ^ col2[i])) val ^= 1;
    if (val) {
      res++;
    }
  }
  cout << res << endl;
}
int main() {
  pls();
  solve();
  return 0;
}
