#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000;
int grid[MAXN][MAXN];
int rowPressCount[2][MAXN];
int colPressCount[2][MAXN];
int diagonalParity[MAXN];
int upperTriangle(int n) {
  int pressCount = 0;
  for (int row = 1; row <= n; row++) {
    for (int col = n; col > row; col--) {
      int parity = (rowPressCount[0][row] + colPressCount[0][col]) % 2;
      if (parity == grid[row][col]) continue;
      rowPressCount[0][row]++;
      colPressCount[0][col]++;
      pressCount++;
    }
    diagonalParity[row] = (rowPressCount[0][row] + colPressCount[0][row]) % 2;
  }
  return pressCount;
}
int lowerTriangle(int n) {
  int pressCount = 0;
  for (int row = n; row >= 1; row--) {
    for (int col = 1; col < row; col++) {
      int parity = (rowPressCount[1][row] + colPressCount[1][col]) % 2;
      if (parity == grid[row][col]) continue;
      rowPressCount[1][row]++;
      colPressCount[1][col]++;
      pressCount++;
    }
    diagonalParity[row] =
        (diagonalParity[row] + rowPressCount[1][row] + colPressCount[1][row]) %
        2;
  }
  return pressCount;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      char c;
      cin >> c;
      if (c == '1') grid[i][j] = 1;
    }
  }
  int ret = upperTriangle(n);
  ret += lowerTriangle(n);
  for (int i = 1; i <= n; i++) {
    if (diagonalParity[i] == grid[i][i]) continue;
    ret++;
  }
  cout << ret << endl;
  return 0;
}
