#include <bits/stdc++.h>
using namespace std;
int i, j, n, a, b;
bool p[2000][2000];
int k[2000][2000], pv[2000], ph[2000], nv[2000], nh[2000];
char s[2012];
int main() {
  scanf("%d", &n);
  for (j = 0; j < n; j++) {
    scanf("%s", s);
    for (i = 0; i < n; i++) p[i][j] = (s[i] == '1');
  }
  for (i = n - 1; i; i--)
    for (j = 0; j < i; j++)
      if (p[i][j] ^ (pv[i] % 2) ^ (ph[j] % 2)) {
        pv[i]++;
        ph[j]++;
      }
  for (j = n - 1; j; j--)
    for (i = 0; i < j; i++)
      if (p[i][j] ^ (nv[i] % 2) ^ (nh[j] % 2)) {
        nv[i]++;
        nh[j]++;
      }
  for (i = 0; i < n; i++) {
    a += nv[i] + nh[i] + pv[i] + ph[i];
    b += p[i][i] ^ (nv[i] + nh[i] + pv[i] + ph[i]) % 2;
  }
  cout << a / 2 + b;
  return 0;
}
