#include <bits/stdc++.h>
using namespace std;
const int MAXn = 2000;
bool rm[MAXn], cm[MAXn];
char t[MAXn][MAXn + 1];
int n;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    for (int j = 0; j < n; j++) t[i][j] -= '0';
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    bool f1 = false, f2 = false;
    for (int j = n - 1; j > i; j--) {
      if (t[i][j] ^ f1 ^ cm[j]) {
        f1 = !f1;
        cm[j] = !cm[j];
        count++;
      }
    }
    for (int j = n - 1; j > i; j--) {
      if (t[j][i] ^ f2 ^ rm[j]) {
        rm[j] = !rm[j];
        f2 = !f2;
        count++;
      }
    }
    if (f1 ^ f2 ^ t[i][i] ^ rm[i] ^ cm[i]) count++;
  }
  cout << count << endl;
  return 0;
}
