#include <bits/stdc++.h>
using namespace std;
bool grid[2004][2004];
bool pending_op_r[2004][2004];
bool pending_op_c[2004][2004];
int grid_size;
int cnt = 0;
int test_row(int row_number, int col_number) {
  while (row_number > col_number) {
    bool pending_op;
    pending_op = pending_op_c[row_number][col_number] ^
                 pending_op_r[row_number][col_number];
    if (grid[row_number][col_number] == pending_op) {
    } else {
      cnt += 1;
      pending_op_r[row_number][col_number] ^= 1;
      pending_op_c[row_number][col_number] ^= 1;
    }
    pending_op_r[row_number - 1][col_number] ^=
        pending_op_r[row_number][col_number];
    pending_op_c[row_number][col_number + 1] ^=
        pending_op_c[row_number][col_number];
    grid[row_number][col_number] = 0;
    row_number--;
  }
}
int test_colomn(int row_number, int col_number) {
  bool pending_op;
  while (row_number > col_number) {
    pending_op = pending_op_c[row_number][col_number] ^
                 pending_op_r[row_number][col_number];
    if (grid[row_number][col_number] == pending_op) {
    } else {
      cnt += 1;
      grid[row_number][col_number] = 0;
      pending_op_c[row_number][col_number] ^= 1;
      pending_op_r[row_number][col_number] ^= 1;
    }
    pending_op_r[row_number - 1][col_number] ^=
        pending_op_r[row_number][col_number];
    pending_op_c[row_number][col_number + 1] ^=
        pending_op_c[row_number][col_number];
    grid[row_number][col_number] = 0;
    col_number++;
  }
}
int test_point(int row_number, int col_number) {
  int pending_op = pending_op_c[row_number][col_number] ^
                   pending_op_r[row_number][col_number];
  if (pending_op ^ grid[row_number][col_number]) {
    cnt++;
    pending_op_c[row_number][col_number] ^= 1;
    pending_op_r[row_number][col_number] ^= 1;
  }
  pending_op_r[row_number - 1][col_number] ^=
      pending_op_r[row_number][col_number];
  pending_op_c[row_number][col_number + 1] ^=
      pending_op_c[row_number][col_number];
  grid[row_number][col_number] = 0;
}
void trans() {
  for (int i = 1; i <= grid_size; i++) {
    for (int j = i + 1; j <= grid_size; j++) {
      grid[j][i] = grid[i][j];
      pending_op_r[j][i] = 0;
      pending_op_c[j][i] = 0;
    }
  }
}
void test() {
  cnt = 0;
  bool pending_op;
  for (int i = grid_size; i > 1 && i > grid_size - i + 1; i--) {
    test_point(i, grid_size - i + 1);
    test_row(i - 1, grid_size - i + 1);
    test_colomn(i, grid_size - i + 2);
  }
  trans();
  for (int i = grid_size; i > 1 && i > grid_size - i + 1; i--) {
    test_point(i, grid_size - i + 1);
    test_row(i - 1, grid_size - i + 1);
    test_colomn(i, grid_size - i + 2);
  }
  for (int i = 1; i <= grid_size; i++) {
    pending_op = pending_op_r[i][i] ^ pending_op_c[i][i];
    cnt += grid[i][i] ^ pending_op;
  }
}
int main() {
  cin >> grid_size;
  char buf[3000];
  for (int i = 1; i <= grid_size; i++) {
    scanf("%s", buf + 1);
    for (int j = 1; j <= grid_size; j++) {
      grid[i][j] = buf[j] - '0';
      pending_op_r[i][j] = 0;
      pending_op_c[i][j] = 0;
    }
  }
  test();
  cout << cnt << endl;
}
