#include <bits/stdc++.h>
using namespace std;
int n, ax[2010], ay[2010], bx[2010], by[2010], ans;
char s[2010][2010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if (s[i][j] == '1' && ax[i] + ay[j] != 1) {
        ans++;
        ax[i] ^= 1;
        ay[j] ^= 1;
      }
      if (s[i][j] == '0' && ax[i] + ay[j] == 1) {
        ans++;
        ax[i] ^= 1;
        ay[j] ^= 1;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      if (s[i][j] == '1' && bx[i] + by[j] != 1) {
        ans++;
        bx[i] ^= 1;
        by[j] ^= 1;
      }
      if (s[i][j] == '0' && bx[i] + by[j] == 1) {
        ans++;
        bx[i] ^= 1;
        by[j] ^= 1;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    int x = ax[i] + bx[i] + ay[i] + by[i];
    if (s[i][i] == '1' && x % 2 == 0) ++ans;
    if (s[i][i] == '0' && x % 2) ++ans;
  }
  cout << ans << endl;
  return 0;
}
