#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int main() {
  int n;
  bool a[2000][2000];
  char s[2001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) a[i][j] = s[j] == '1';
  }
  bool right[2000] = {false};
  bool left[2000] = {false};
  bool top[2000] = {false};
  bool bottom[2000] = {false};
  int z = 0;
  for (int i = 0; i < n; i++) {
    int row_start = i;
    int col_start = i;
    int row_end = n - i - 1;
    int col_end = n - i - 1;
    if (row_start > row_end) break;
    if (col_start > col_end) break;
    if (row_start == row_end) {
      bool tb = top[col_start] ^ bottom[col_start];
      bool rl = right[row_start] ^ left[row_start];
      bool common = tb ^ rl;
      if (a[row_start][col_start] ^ common) {
        z++;
      }
      continue;
    }
    for (int col = col_end; col > col_start; col--) {
      bool v = right[row_start] ^ top[col];
      if (a[row_start][col] ^ v) {
        top[col] ^= true;
        right[row_start] ^= true;
        z++;
      }
    }
    for (int row = row_end; row > row_start; row--) {
      bool v2 = left[row] ^ bottom[col_start];
      if (a[row][col_start] ^ v2) {
        v2 ^= true;
        left[row] ^= true;
        bottom[col_start] ^= true;
        z++;
      }
    }
    bool v = right[row_start] ^ top[col_start];
    bool v2 = left[row_start] ^ bottom[col_start];
    v ^= v2;
    if (a[row_start][col_start] ^ v) {
      z++;
    }
    for (int row = row_start + 1; row < row_end; row++) {
      bool w = right[row] ^ top[col_end];
      if (a[row][col_end] ^ w) {
        right[row] ^= true;
        top[col_end] ^= true;
        z++;
      }
    }
    for (int col = col_start + 1; col < col_end; col++) {
      bool w2 = left[row_end] ^ bottom[col];
      if (a[row_end][col] ^ w2) {
        bottom[col] ^= true;
        left[row_end] ^= true;
        z++;
      }
    }
    bool w = right[row_end] ^ top[col_end];
    bool w2 = left[row_end] ^ bottom[col_end];
    w ^= w2;
    if (a[row_end][col_end] ^ w) {
      z++;
    }
  }
  cout << z << endl;
  return (0);
}
