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