#include <bits/stdc++.h>
using namespace std;
int n;
char s[2001][2002];
int wu[2][2001];
int ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++) {
    int rxor = 0, lxor = 0, d;
    for (int j = n; j > i; j--) {
      d = wu[0][j] ^ (s[i][j] - '0') ^ rxor;
      if (d) ans++, rxor ^= 1, wu[0][j] ^= 1;
      d = wu[1][j] ^ (s[j][i] - '0') ^ lxor;
      if (d) ans++, lxor ^= 1, wu[1][j] ^= 1;
    }
    if ((s[i][i] - '0') ^ rxor ^ lxor ^ wu[0][i] ^ wu[1][i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
