#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 100;
int n;
char s[maxn][maxn];
char r1[maxn], c1[maxn];
char r2[maxn], c2[maxn];
int ans;
int main() {
  scanf("%d ", &n);
  for (int i = 0, _n = (int)(n); i < _n; i++) gets(s[i]);
  for (int i = 0, _n = (int)(n); i < _n; i++)
    for (int j = 0, _n = (int)(n); j < _n; j++) s[i][j] -= '0';
  for (int i = 0, _n = (int)(n); i < _n; i++)
    for (int j = (int)(n), _x = (int)(i + 1); j-- > _x;)
      if (r1[i] ^ c1[j] ^ s[i][j]) ans++, r1[i] ^= 1, c1[j] ^= 1;
  for (int i = (int)(n), _x = (int)(0); i-- > _x;)
    for (int j = 0, _n = (int)(i); j < _n; j++)
      if (r2[i] ^ c2[j] ^ s[i][j]) ans++, r2[i] ^= 1, c2[j] ^= 1;
  for (int i = 0, _n = (int)(n); i < _n; i++)
    if (r1[i] ^ c1[i] ^ r2[i] ^ c2[i] ^ s[i][i]) ans++;
  printf("%d\n", ans);
  {
    int _;
    cin >> _;
  }
}
