#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > v(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      v[i][j] = c - '0';
    }
  }
  vector<int> f(n, 0);
  vector<int> c(n, 0);
  int count = 0;
  for (int k = 0; k < n; k++) {
    int cc = 0;
    for (int j = n - 1; j > k; j--) {
      if ((v[k][j] + c[j] + cc) % 2 == 1) {
        c[j] = 1 - c[j];
        cc = 1 - cc;
        count++;
        v[j][j] = 1 - v[j][j];
      }
    }
    int ff = 0;
    for (int i = n - 1; i > k; i--) {
      if ((v[i][k] + f[i] + ff) % 2 == 1) {
        f[i] = 1 - f[i];
        ff = 1 - ff;
        count++;
        v[i][i] = 1 - v[i][i];
      }
    }
    if ((v[k][k] + ff + cc) % 2 == 1) count++;
  }
  cout << count << endl;
}
