#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
template <class T>
inline T sq(T x) {
  return x * x;
}
template <class T>
inline void upd_min(T &lhs, T rhs) {
  if (lhs > rhs) lhs = rhs;
}
template <class T>
inline void upd_max(T &lhs, T rhs) {
  if (lhs < rhs) lhs = rhs;
}
void solve() {
  int n;
  cin >> n;
  int **data = new int *[n];
  for (int y = (0); y < (n); ++y) {
    data[y] = new int[n];
    for (int x = (0); x < (n); ++x) {
      char c;
      cin >> c;
      data[y][x] = c & 1;
    }
  }
  int z = 0;
  int revY1[1 << 11] = {};
  int revX1[1 << 11] = {};
  for (int y = n - 1; y > 0; --y) {
    for (int x = 0; x < y; ++x) {
      if (data[y][x] ^ revY1[y] ^ revX1[x]) {
        ++z;
        revY1[y] = !revY1[y];
        revX1[x] = !revX1[x];
      }
    }
  }
  int revY2[1 << 11] = {};
  int revX2[1 << 11] = {};
  for (int x = n - 1; x > 0; --x) {
    for (int y = 0; y < x; ++y) {
      if (data[y][x] ^ revY2[y] ^ revX2[x]) {
        ++z;
        revY2[y] = !revY2[y];
        revX2[x] = !revX2[x];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    z += data[i][i] ^ revY1[i] ^ revX1[i] ^ revY2[i] ^ revX2[i];
  }
  cout << z << endl;
  for (int y = (0); y < (n); ++y) {
    delete[] data[y];
  }
  delete[] data;
}
int main() {
  solve();
  return 0;
}
