#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> map(n);
  for (int i = 0; i < n; ++i) {
    map[i].resize(n);
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      map[i][j] = c - '0';
    }
  }
  vector<int> cols(n);
  vector<int> diag(n);
  int paint = 0;
  for (int i = 0; i < n; ++i) {
    int row = 0;
    for (int j = n - 1; j > i; --j) {
      if (map[i][j] != (row ^ cols[j])) {
        paint++;
        cols[j] ^= 1;
        row ^= 1;
        diag[i] ^= 1;
        diag[j] ^= 1;
      }
    }
  }
  for_each(cols.begin(), cols.end(), [](int& x) { x = 0; });
  for (int i = n - 1; i >= 0; --i) {
    int row = 0;
    for (int j = 0; j < i; ++j) {
      if (map[i][j] != (row ^ cols[j])) {
        paint++;
        cols[j] ^= 1;
        row ^= 1;
        diag[i] ^= 1;
        diag[j] ^= 1;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (diag[i] != map[i][i]) {
      paint++;
    }
  }
  cout << paint << endl;
  return 0;
}
