#include <bits/stdc++.h>
using namespace std;
int col[2010];
int row[2010];
int b[2001][2001];
int diag[2010];
int main() {
  int n;
  cin >> n;
  string line;
  for (int i = 0; i < n; i++) {
    cin >> line;
    for (int j = 0; j < n; j++)
      if (line[j] == '1')
        b[n - 1 - j][i] = 1;
      else
        b[n - 1 - j][i] = 0;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) row[i] = col[i] = 0;
  for (int k = 0; k < n / 2; k++) {
    for (int x = k; x < n - k - 1; x++) {
      if ((row[k] + col[x] + b[k][x]) % 2) {
        row[k]++;
        col[x]++;
        cnt++;
      }
    }
    for (int y = k + 1; y < n - k - 1; y++) {
      if ((col[k] + row[y] + b[y][k]) % 2) {
        row[y]++;
        col[k]++;
        cnt++;
      }
    }
  }
  for (int k = 0; k < n; k++) diag[k] = row[k] + col[n - 1 - k];
  for (int i = 0; i < n; i++) row[i] = col[i] = 0;
  for (int k = n - 1; k >= (n + 1) / 2; k--) {
    for (int x = k; x >= n - k; x--) {
      if ((row[k] + col[x] + b[k][x]) % 2) {
        row[k]++;
        col[x]++;
        cnt++;
      }
    }
    for (int y = k - 1; y >= n - k; y--) {
      if ((col[k] + row[y] + b[y][k]) % 2) {
        col[k]++;
        row[y]++;
        cnt++;
      }
    }
  }
  for (int i = 0; i < n; i++) diag[i] += row[i] + col[n - 1 - i];
  for (int i = 0; i < n; i++) {
    if ((diag[i] + b[i][n - 1 - i]) % 2) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
