#include <bits/stdc++.h>
char board[2001][2001];
bool a[2001];
bool b[2001];
bool c[2001];
bool d[2001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", board[i]);
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = n - 1; j > i; j--) {
      if (((board[i][j] == '1') + a[i] + b[j]) % 2) {
        a[i] = !a[i];
        b[j] = !b[j];
        ans++;
      }
    }
  }
  for (int i = n - 1; i >= 1; i--) {
    for (int j = 0; j < i; j++) {
      if (((board[i][j] == '1') + c[i] + d[j]) % 2) {
        c[i] = !c[i];
        d[j] = !d[j];
        ans++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (((board[i][i] == '1') + a[i] + b[i] + c[i] + d[i]) % 2) ans++;
  }
  printf("%d", ans);
}
