#include <bits/stdc++.h>
using namespace std;
string s[2010];
int row[2010], col[2010];
int diag[2010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  memset(row, 0, sizeof(row));
  memset(col, 0, sizeof(col));
  int total = 0;
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; j--) {
      if ((s[i][j] == '0' and ((row[i] + col[j]) % 2) != 0) or
          (s[i][j] == '1' and ((row[i] + col[j]) % 2) != 1)) {
        row[i]++;
        col[j]++;
        total++;
      }
    }
  for (int i = 0; i < n; i++) {
    diag[i] = row[i] + col[i];
  }
  memset(row, 0, sizeof(row));
  memset(col, 0, sizeof(col));
  for (int i = n - 1; i > 0; i--)
    for (int j = 0; j < i; j++) {
      if ((s[i][j] == '0' and ((row[i] + col[j]) % 2) != 0) or
          (s[i][j] == '1' and ((row[i] + col[j]) % 2) != 1)) {
        row[i]++;
        col[j]++;
        total++;
      }
    }
  for (int i = 0; i < n; i++) {
    diag[i] += row[i] + col[i];
    if (((diag[i] % 2) == 0 and s[i][i] == '1') or
        ((diag[i] % 2) == 1 and s[i][i] == '0'))
      total++;
  }
  cout << total << endl;
  return 0;
}
