#include <bits/stdc++.h>
using namespace std;
string a[2006];
int row[2006], cal[2006];
int w[2006];
int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      int t = cal[j] + row[i];
      if ((t % 2 == 0 && a[i][j] == '1') || (a[i][j] == '0' && t % 2 == 1)) {
        cal[j]++;
        row[i]++;
        ans++;
        w[j]++;
        w[i]++;
      }
    }
  }
  for (int i = 0; i < 2006; i++) row[i] = cal[i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      int t = cal[j] + row[i];
      if ((t % 2 == 0 && a[i][j] == '1') || (a[i][j] == '0' && t % 2 == 1)) {
        cal[j]++;
        row[i]++;
        ans++;
        w[j]++;
        w[i]++;
      }
    }
  }
  for (int i = 0; i < n; i++)
    if ((a[i][i] == '1' && w[i] % 2 == 0) || (a[i][i] == '0' && w[i] % 2 == 1))
      ans++;
  cout << ans << endl;
  return 0;
}
