#include <bits/stdc++.h>
const long double PI(acosl(-1.0));
using namespace std;
const int N = 2020;
int v[N][N], t[N][N];
bool col[N], diag[N];
int main() {
  cout.precision(10);
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(unsigned(time(nullptr)));
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < n; ++j) v[i][j] = s[j] - '0';
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    bool inv = false;
    for (int j = n - 1; j > i; --j) {
      bool cur = t[i][j] ^ inv ^ col[j];
      if (cur != v[i][j]) {
        diag[i] ^= 1;
        diag[j] ^= 1;
        col[j] ^= 1;
        inv ^= 1;
        ++ans;
      }
    }
  }
  fill(col, col + N, 0);
  for (int i = n - 1; i >= 0; --i) {
    bool inv = false;
    for (int j = 0; j < i; ++j) {
      bool cur = t[i][j] ^ inv ^ col[j];
      if (cur != v[i][j]) {
        diag[i] ^= 1;
        diag[j] ^= 1;
        col[j] ^= 1;
        inv ^= 1;
        ++ans;
      }
    }
  }
  for (int i = 0; i < n; ++i)
    if (diag[i] != v[i][i]) ++ans;
  cout << ans;
}
