#include <bits/stdc++.h>
int v[2002][2002], c[2002][2002], r[2002][2002], x[2002];
char ch[2005];
int main() {
  int i, j, n, sol = 0;
  scanf("%d\n", &n);
  for (i = 1; i <= n; ++i) {
    fgets(ch, sizeof(ch), stdin);
    for (j = 0; j < n; ++j) v[i][j + 1] = ch[j] - '0';
  }
  for (i = 1; i < n; ++i)
    for (j = n; j > i; --j) {
      c[i][j] += c[i - 1][j];
      r[i][j] += r[i][j + 1];
      if ((v[i][j] + c[i][j] + r[i][j]) & 1) {
        ++sol;
        c[i + 1][j] ^= 1;
        r[i][j - 1] ^= 1;
        x[i] ^= 1;
        x[j] ^= 1;
      }
    }
  for (i = n; i > 1; --i)
    for (j = 1; j < i; ++j) {
      c[i][j] += c[i + 1][j];
      r[i][j] += r[i][j - 1];
      if ((v[i][j] + c[i][j] + r[i][j]) & 1) {
        ++sol;
        c[i - 1][j] ^= 1;
        r[i][j + 1] ^= 1;
        x[i] ^= 1;
        x[j] ^= 1;
      }
    }
  for (i = 1; i <= n; ++i) sol += (x[i] + v[i][i]) & 1;
  printf("%d\n", sol);
  return 0;
}
