#include <bits/stdc++.h>
using namespace std;
char d[2005][2005];
int f[2005][2005], p[2005][2005], q[2005][2005], n, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", d[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) f[i][j] = d[i][j] - '0';
  for (int i = 1; i <= n; i++)
    for (int j = n; j >= i; j--) {
      q[i][j] ^= q[i][j + 1];
      p[i][j] ^= p[i - 1][j];
      if (p[i][j] ^ q[i][j] != f[i][j] && i != j) {
        p[i][j] ^= 1;
        q[i][j] ^= 1;
        ans++;
      }
    }
  for (int i = n; i >= 1; i--)
    for (int j = 1; j <= i; j++) {
      p[i][j] ^= p[i + 1][j];
      q[i][j] ^= q[i][j - 1];
      if (p[i][j] ^ q[i][j] != f[i][j] && i != j) {
        p[i][j] ^= 1;
        q[i][j] ^= 1;
        ans++;
      }
    }
  for (int i = 1; i <= n; i++)
    if (q[i][i] ^ p[i][i] != f[i][i]) ans++;
  printf("%d\n", ans);
}
