#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
int n;
char s[2222][2222];
bool inv_row[2222];
bool inv_col[2222];
int main() {
  cin >> n;
  gets(s[0]);
  for (int i(0); i < (n); i++) gets(s[i]);
  int res = 0;
  while (n) {
    bool curr_inv1 = 0;
    for (int i(0); i < (n - 1); i++) {
      bool black = (s[n - 1][i] == '1');
      black ^= curr_inv1;
      black ^= inv_col[i];
      if (black) {
        res++;
        inv_col[i] ^= 1;
        curr_inv1 ^= 1;
      }
    }
    bool curr_inv2 = 0;
    for (int i(0); i < (n - 1); i++) {
      bool black = (s[i][n - 1] == '1');
      black ^= curr_inv2;
      black ^= inv_row[i];
      if (black) {
        res++;
        inv_row[i] ^= 1;
        curr_inv2 ^= 1;
      }
    }
    bool bl = s[n - 1][n - 1] == '1';
    bl ^= curr_inv1;
    bl ^= curr_inv2;
    bl ^= inv_row[n - 1];
    bl ^= inv_col[n - 1];
    if (bl) res++;
    n--;
  }
  cout << res << endl;
  return 0;
}
