#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2100;
int mat[MAXN][MAXN];
char str[MAXN][MAXN];
int cnt[MAXN];
int single[MAXN];
int N;
int work() {
  int ans = 0;
  memset(single, 0, sizeof(single));
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= N; i++) {
    int cur = 0;
    for (int j = N; j > i; j--) {
      if (((cnt[j] + cur) & 1) != mat[i][j]) {
        cur++;
        cnt[j]++;
        ans++;
        single[i]++;
        single[j]++;
      }
    }
  }
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= N; i++) {
    int cur = 0;
    for (int j = N; j > i; j--) {
      if (((cnt[j] + cur) & 1) != mat[j][i]) {
        cur++;
        cnt[j]++;
        ans++;
        single[i]++;
        single[j]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    if (mat[i][i] != (single[i] & 1)) {
      ans++;
    }
  }
  return ans;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%s", str[i]);
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      mat[i][j] = str[i - 1][j - 1] - '0';
    }
  }
  int ans = work();
  printf("%d\n", ans);
  return 0;
}
